Page MenuHomeFreeBSD

D57062.id178068.diff
No OneTemporary

D57062.id178068.diff

diff --git a/usr.sbin/bhyve/pci_fbuf.c b/usr.sbin/bhyve/pci_fbuf.c
--- a/usr.sbin/bhyve/pci_fbuf.c
+++ b/usr.sbin/bhyve/pci_fbuf.c
@@ -453,7 +453,8 @@
memset((void *)sc->fb_base, 0, FB_SIZE);
error = rfb_init(sc->rfb_family, sc->rfb_host, sc->rfb_port,
- sc->rfb_wait, sc->rfb_password);
+ sc->rfb_wait, sc->rfb_password, sc->memregs.width,
+ sc->memregs.height);
done:
if (error)
free(sc);
diff --git a/usr.sbin/bhyve/rfb.h b/usr.sbin/bhyve/rfb.h
--- a/usr.sbin/bhyve/rfb.h
+++ b/usr.sbin/bhyve/rfb.h
@@ -31,9 +31,11 @@
#include <sys/socket.h>
+#include <stdint.h>
+
#define RFB_PORT 5900
int rfb_init(sa_family_t family, const char *hostname, int port, int wait,
- const char *password);
+ const char *password, uint16_t width, uint16_t height);
#endif /* _RFB_H_ */
diff --git a/usr.sbin/bhyve/rfb.c b/usr.sbin/bhyve/rfb.c
--- a/usr.sbin/bhyve/rfb.c
+++ b/usr.sbin/bhyve/rfb.c
@@ -192,9 +192,7 @@
#define RFB_CLIENTMSG_EXT_KEYEVENT 0
-#define RFB_MAX_WIDTH 2000
-#define RFB_MAX_HEIGHT 1200
-#define RFB_ZLIB_BUFSZ RFB_MAX_WIDTH*RFB_MAX_HEIGHT*4
+#define RFB_ZLIB_COUNT_BUFFER_SIZE(gc) (gc->width * gc->height * 4)
#define PIXEL_RED_SHIFT 16
#define PIXEL_GREEN_SHIFT 8
@@ -546,8 +544,8 @@
rc->zstream.next_in = (Bytef *)pixelp;
rc->zstream.avail_in = w;
rc->zstream.next_out = (Bytef *)zbufp;
- rc->zstream.avail_out = RFB_ZLIB_BUFSZ + 16 -
- rc->zstream.total_out;
+ rc->zstream.avail_out = RFB_ZLIB_COUNT_BUFFER_SIZE(gc) +
+ 16 - rc->zstream.total_out;
rc->zstream.data_type = Z_BINARY;
/* Compress with zlib */
@@ -634,7 +632,7 @@
rc->zstream.avail_in = gc->width * gc->height *
sizeof(uint32_t);
rc->zstream.next_out = (Bytef *)rc->zbuf;
- rc->zstream.avail_out = RFB_ZLIB_BUFSZ + 16;
+ rc->zstream.avail_out = RFB_ZLIB_COUNT_BUFFER_SIZE(gc) + 16;
rc->zstream.data_type = Z_BINARY;
rc->zstream.total_in = 0;
@@ -724,9 +722,9 @@
/* Clear old CRC values when the size changes */
if (rc->crc_width != gc_image->width ||
rc->crc_height != gc_image->height) {
- memset(rc->crc, 0, sizeof(uint32_t) *
- howmany(RFB_MAX_WIDTH, PIX_PER_CELL) *
- howmany(RFB_MAX_HEIGHT, PIX_PER_CELL));
+ memset(rc->crc, 0,
+ sizeof(uint32_t) * howmany(gc_image->width, PIX_PER_CELL) *
+ howmany(gc_image->height, PIX_PER_CELL));
rc->crc_width = gc_image->width;
rc->crc_height = gc_image->height;
}
@@ -1227,7 +1225,8 @@
goto done;
if (!rc->zbuf) {
- rc->zbuf = malloc(RFB_ZLIB_BUFSZ + 16);
+ rc->zbuf = malloc(
+ RFB_ZLIB_COUNT_BUFFER_SIZE(console_get_image()) + 16);
assert(rc->zbuf != NULL);
}
@@ -1339,7 +1338,7 @@
int
rfb_init(sa_family_t family, const char *hostname, int port, int wait,
- const char *password)
+ const char *password, uint16_t width, uint16_t height)
{
int e;
char servname[6];
@@ -1355,12 +1354,11 @@
rc = calloc(1, sizeof(struct rfb_softc));
- cnt = howmany(RFB_MAX_WIDTH, PIX_PER_CELL) *
- howmany(RFB_MAX_HEIGHT, PIX_PER_CELL);
+ cnt = howmany(width, PIX_PER_CELL) * howmany(height, PIX_PER_CELL);
rc->crc = calloc(cnt, sizeof(uint32_t));
rc->crc_tmp = calloc(cnt, sizeof(uint32_t));
- rc->crc_width = RFB_MAX_WIDTH;
- rc->crc_height = RFB_MAX_HEIGHT;
+ rc->crc_width = width;
+ rc->crc_height = height;
rc->sfd = -1;
rc->password = password;
@@ -1372,7 +1370,7 @@
goto error;
}
- rc->pixrow = malloc(RFB_MAX_WIDTH * sizeof(uint32_t));
+ rc->pixrow = malloc(width * sizeof(uint32_t));
if (rc->pixrow == NULL) {
EPRINTLN("rfb: failed to allocate memory for pixrow buffer");
goto error;

File Metadata

Mime Type
text/plain
Expires
Tue, Sep 1, 4:40 PM (14 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37839037
Default Alt Text
D57062.id178068.diff (3 KB)

Event Timeline