[Spice-commits] Branch 'spice.v16' - 6 commits - arch_init.c hw/qxl.c hw/qxl.h hw/vga_int.h qemu-options.hx savevm.c ui/spice-core.c

Gerd Hoffmann kraxel at kemper.freedesktop.org
Thu Aug 26 15:15:36 PDT 2010


 arch_init.c     |    9 +++-
 hw/qxl.c        |  125 +++++++++++++++++++++++++++++++++++++++++---------------
 hw/qxl.h        |    6 ++
 hw/vga_int.h    |    2 
 qemu-options.hx |   27 +++++++++++-
 savevm.c        |    6 ++
 ui/spice-core.c |    4 +
 7 files changed, 143 insertions(+), 36 deletions(-)

New commits:
commit 57408ef9ecd30209d4d060f64d30d5ceaa041b39
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Aug 26 14:29:31 2010 +0200

    core: diable spice client migration bits

diff --git a/ui/spice-core.c b/ui/spice-core.c
index dfa9339..98a7f11 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -186,6 +186,7 @@ static const char *wan_compression_names[] = {
     parse_name(_name, "wan compression",                                \
                wan_compression_names, ARRAY_SIZE(wan_compression_names))
 
+#if 0
 /* handle client migration */
 
 static int spice_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
@@ -250,6 +251,7 @@ static int spice_load(QEMUFile *f, void *opaque, int version_id)
     fprintf(stderr, "%s:\n", __FUNCTION__);
     return 0;
 }
+#endif
 
 /* functions for the rest of qemu */
 
@@ -372,9 +374,11 @@ void qemu_spice_init(void)
     qemu_spice_input_init();
     qemu_spice_audio_init();
 
+#if 0
     register_savevm_live(NULL, "spice", -1, 1, NULL,
                          spice_live, spice_save, spice_load,
                          spice_server);
+#endif
 
     qemu_free(x509_key_file);
     qemu_free(x509_cert_file);
commit 1e4e2bcccfa06c4b015bf7c063f0bccb2f82c7c0
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Aug 26 13:04:14 2010 +0200

    [debug] loadvm logging

diff --git a/arch_init.c b/arch_init.c
index e468c0c..2003bd6 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -346,6 +346,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
         if (flags & RAM_SAVE_FLAG_MEM_SIZE) {
             if (version_id == 3) {
                 if (addr != ram_bytes_total()) {
+                    fprintf(stderr, "%s: v3 size mismatch\n", __FUNCTION__);
                     return -EINVAL;
                 }
             } else {
@@ -365,8 +366,13 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
 
                     QLIST_FOREACH(block, &ram_list.blocks, next) {
                         if (!strncmp(id, block->idstr, sizeof(id))) {
-                            if (block->length != length)
+                            if (block->length != length) {
+                                fprintf(stderr, "%s: block \"%s\" size mismatch, "
+                                        "got 0x%lx, want 0x%lx\n",
+                                        __FUNCTION__, block->idstr,
+                                        length, block->length);
                                 return -EINVAL;
+                            }
                             break;
                         }
                     }
@@ -410,6 +416,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
             qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
         }
         if (qemu_file_has_error(f)) {
+            fprintf(stderr, "%s: i/o error\n", __FUNCTION__);
             return -EIO;
         }
     } while (!(flags & RAM_SAVE_FLAG_EOS));
diff --git a/savevm.c b/savevm.c
index 99e4949..0c8844b 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1710,6 +1710,10 @@ int qemu_loadvm_state(QEMUFile *f)
                 goto out;
             }
 
+            fprintf(stderr, "%s: name \"%s\", version %d, instance %d, %s\n",
+                    __FUNCTION__, idstr, version_id, instance_id,
+                    se->vmsd ? "vmsd" : "func");
+
             /* Validate version */
             if (version_id > se->version_id) {
                 fprintf(stderr, "savevm: unsupported version %d for '%s' v%d\n",
@@ -1775,6 +1779,8 @@ out:
     if (qemu_file_has_error(f))
         ret = -EIO;
 
+    fprintf(stderr, "%s: done, %s\n", __FUNCTION__,
+            ret == 0 ? "success" : "failure");
     return ret;
 }
 
commit 2a4c2a49c6f839d248a9ad10f65b8dd02a8fcd7e
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Aug 26 13:03:50 2010 +0200

    [rhel6 compat] adjust vga ram size

diff --git a/hw/vga_int.h b/hw/vga_int.h
index beb5423..0ac09e2 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -226,7 +226,7 @@ void vga_init_vbe(VGACommonState *s);
 extern const uint8_t sr_mask[8];
 extern const uint8_t gr_mask[16];
 
-#define VGA_RAM_SIZE (8192 * 1024)
+#define VGA_RAM_SIZE (16 * 1024 * 1024)
 #define VGABIOS_FILENAME "vgabios.bin"
 #define VGABIOS_CIRRUS_FILENAME "vgabios-cirrus.bin"
 
commit 11d16d53ed5a57d007c3b0ba17f72d988e200c08
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Aug 26 11:57:02 2010 +0200

    spice: document image compression options

diff --git a/qemu-options.hx b/qemu-options.hx
index 056b9b4..9f3e3d2 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -704,6 +704,15 @@ The x509 file names can also be configured individually.
 @item tls-ciphers=<list>
 Specify which ciphers to use.
 
+ at item image-compression=[auto_glz|auto_lz|quic|glz|lz|off]
+Configure image compression (lossless).
+Default is auto_glz.
+
+ at item jpeg-wan-compression=[auto|never|allways]
+ at item zlib-glz-wan-compression=[auto|never|allways]
+Configure wan image compression (lossy for slow links).
+Default is auto.
+
 @end table
 ETEXI
 
commit ede9c99ac089f2b7b30aaa3d5cabebbeecd6b2ba
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Aug 26 11:47:50 2010 +0200

    spice: document tls options

diff --git a/qemu-options.hx b/qemu-options.hx
index 87bd451..056b9b4 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -680,7 +680,7 @@ Enable the spice remote desktop protocol. Valid options are
 @table @option
 
 @item port=<nr>
-Set the TCP port spice is listening on.
+Set the TCP port spice is listening on for plaintext channels.
 
 @item password=<secret>
 Set the password you need to authenticate.
@@ -688,6 +688,22 @@ Set the password you need to authenticate.
 @item disable-ticketing
 Allow client connects without authentication.
 
+ at item tls-port=<nr>
+Set the TCP port spice is listening on for encrypted channels.
+
+ at item x509-dir=<dir>
+Set the x509 file directory. Expects same filenames as -vnc $display,x509=$dir
+
+ at item x509-key-file=<file>
+ at item x509-key-password=<file>
+ at item x509-cert-file=<file>
+ at item x509-cacert-file=<file>
+ at item x509-dh-key-file=<file>
+The x509 file names can also be configured individually.
+
+ at item tls-ciphers=<list>
+Specify which ciphers to use.
+
 @end table
 ETEXI
 
commit aa3958ef6c2f70a0737a299dd992ff634074d84e
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Wed Aug 25 18:08:37 2010 +0200

    qxl: savevm fixes

diff --git a/hw/qxl.c b/hw/qxl.c
index 7cc543d..75bddda 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1090,6 +1090,14 @@ static void qxl_vm_change_state_handler(void *opaque, int running, int reason)
 {
     PCIQXLDevice *qxl = opaque;
     qemu_spice_vm_change_state_handler(&qxl->ssd, running, reason);
+
+    if (!running && qxl->mode == QXL_MODE_NATIVE) {
+        /* dirty all vram (which holds surfaces) to make sure it is saved */
+        /* FIXME #1: should go out during "live" stage */
+        /* FIXME #2: we only need to save the areas which are actually used */
+        ram_addr_t addr = qxl->vram_offset;
+        qxl_set_dirty(addr, addr + qxl->vram_size);
+    }
 }
 
 /* display change listener */
@@ -1137,6 +1145,8 @@ static int qxl_init(PCIDevice *dev)
     qxl->id = device_id;
     qxl->mode = QXL_MODE_UNDEFINED;
     qxl->generation = 1;
+    qxl->num_memslots = NUM_MEMSLOTS;
+    qxl->num_surfaces = NUM_SURFACES;
 
     switch (qxl->revision) {
     case 1: /* spice 0.4 -- qxl-1 */
@@ -1186,7 +1196,8 @@ static int qxl_init(PCIDevice *dev)
         if (ram_size < 16 * 1024 * 1024)
             ram_size = 16 * 1024 * 1024;
         qxl->vga.vram_size = ram_size;
-        qxl->vga.vram_offset = qemu_ram_alloc(&qxl->pci.qdev, "bar0", qxl->vga.vram_size);
+        qxl->vga.vram_offset = qemu_ram_alloc(&qxl->pci.qdev, "qxl.vgavram",
+                                              qxl->vga.vram_size);
         qxl->vga.vram_ptr = qemu_get_ram_ptr(qxl->vga.vram_offset);
 
         pci_config_set_class(config, PCI_CLASS_DISPLAY_OTHER);
@@ -1198,7 +1209,7 @@ static int qxl_init(PCIDevice *dev)
     pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
 
     qxl->rom_size = qxl_rom_size();
-    qxl->rom_offset = qemu_ram_alloc(&qxl->pci.qdev, "bar2", qxl->rom_size);
+    qxl->rom_offset = qemu_ram_alloc(&qxl->pci.qdev, "qxl.vrom", qxl->rom_size);
     init_qxl_rom(qxl);
     init_qxl_ram(qxl);
 
@@ -1207,7 +1218,7 @@ static int qxl_init(PCIDevice *dev)
     if (qxl->revision == 1)
         qxl->vram_size = 4096;
     qxl->vram_size = msb_mask(qxl->vram_size * 2 - 1);
-    qxl->vram_offset = qemu_ram_alloc(&qxl->pci.qdev, "bar1", qxl->vram_size);
+    qxl->vram_offset = qemu_ram_alloc(&qxl->pci.qdev, "qxl.vram", qxl->vram_size);
 
     pci_register_bar(&qxl->pci, QXL_IO_RANGE_INDEX,
                      msb_mask(QXL_IO_RANGE_SIZE * 2 - 1),
@@ -1242,14 +1253,12 @@ static void qxl_pre_save(void *opaque)
     uint8_t *ram_start = d->vga.vram_ptr;
 
     dprintf(d, 1, "%s:\n", __FUNCTION__);
-#if 1 /* wanna zap this */
     if (d->last_release == NULL) {
         d->last_release_offset = 0;
     } else {
         d->last_release_offset = (uint8_t *)d->last_release - ram_start;
     }
     assert(d->last_release_offset < d->vga.vram_size);
-#endif
 }
 
 static int qxl_pre_load(void *opaque)
@@ -1311,29 +1320,55 @@ static int qxl_post_load(void *opaque, int version)
     }
     dprintf(d, 1, "%s: done\n", __FUNCTION__);
 
-#if 1 /* wanna zap this */
-    if (d->last_release_offset >= d->vga.vram_size) {
-        dprintf(d, 1, "%s: invalid last_release_offset %u, ram_size %u\n",
-                __FUNCTION__, d->last_release_offset, d->vga.vram_size);
-        exit(-1);
-    }
-
+    assert(d->last_release_offset < d->vga.vram_size);
     if (d->last_release_offset == 0) {
         d->last_release = NULL;
     } else {
         d->last_release = (QXLReleaseInfo *)(ram_start + d->last_release_offset);
     }
-#endif
+
+    /* spice 0.4 compatibility -- accept but ignore */
+    free(d->worker_data);
+    d->worker_data = NULL;
+    d->worker_data_size = 0;
 
     return 0;
 }
 
-#define QXL_VER 1
+#define QXL_SAVE_VERSION 20
+
+static bool qxl_test_worker_data(void *opaque, int version_id)
+{
+    PCIQXLDevice* d = opaque;
+
+    if (d->revision != 1) {
+        return false;
+    }
+    if (!d->worker_data_size) {
+        return false;
+    }
+    if (!d->worker_data) {
+        d->worker_data = qemu_malloc(d->worker_data_size);
+    }
+    return true;
+}
+
+static bool qxl_test_spice04(void *opaque, int version_id)
+{
+    PCIQXLDevice* d = opaque;
+    return d->revision == 1;
+}
+
+static bool qxl_test_spice06(void *opaque)
+{
+    PCIQXLDevice* d = opaque;
+    return d->revision > 1;
+}
 
 static VMStateDescription qxl_memslot = {
     .name               = "qxl-memslot",
-    .version_id         = QXL_VER,
-    .minimum_version_id = QXL_VER,
+    .version_id         = QXL_SAVE_VERSION,
+    .minimum_version_id = QXL_SAVE_VERSION,
     .fields = (VMStateField[]) {
         VMSTATE_UINT64(slot.mem_start, struct guest_slots),
         VMSTATE_UINT64(slot.mem_end,   struct guest_slots),
@@ -1344,8 +1379,8 @@ static VMStateDescription qxl_memslot = {
 
 static VMStateDescription qxl_surface = {
     .name               = "qxl-surface",
-    .version_id         = QXL_VER,
-    .minimum_version_id = QXL_VER,
+    .version_id         = QXL_SAVE_VERSION,
+    .minimum_version_id = QXL_SAVE_VERSION,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(width,      QXLSurfaceCreate),
         VMSTATE_UINT32(height,     QXLSurfaceCreate),
@@ -1360,34 +1395,58 @@ static VMStateDescription qxl_surface = {
     }
 };
 
+static VMStateDescription qxl_vmstate_spice06 = {
+    .name               = "qxl/spice06",
+    .version_id         = QXL_SAVE_VERSION,
+    .minimum_version_id = QXL_SAVE_VERSION,
+    .fields = (VMStateField []) {
+        VMSTATE_INT32_EQUAL(num_memslots, PCIQXLDevice),
+        VMSTATE_STRUCT_ARRAY(guest_slots, PCIQXLDevice, NUM_MEMSLOTS, 0,
+                             qxl_memslot, struct guest_slots),
+        VMSTATE_STRUCT(guest_primary.surface, PCIQXLDevice, 0,
+                       qxl_surface, QXLSurfaceCreate),
+        VMSTATE_INT32_EQUAL(num_surfaces, PCIQXLDevice),
+        VMSTATE_ARRAY(guest_surfaces.cmds, PCIQXLDevice, NUM_SURFACES, 0,
+                      vmstate_info_uint64, uint64_t),
+        VMSTATE_UINT64(guest_cursor, PCIQXLDevice),
+        VMSTATE_END_OF_LIST()
+    },
+};
+
 static VMStateDescription qxl_vmstate = {
     .name               = "qxl",
-    .version_id         = QXL_VER,
-    .minimum_version_id = QXL_VER,
+    .version_id         = QXL_SAVE_VERSION,
+    .minimum_version_id = QXL_SAVE_VERSION,
     .pre_save           = qxl_pre_save,
     .pre_load           = qxl_pre_load,
     .post_load          = qxl_post_load,
     .fields = (VMStateField []) {
         VMSTATE_PCI_DEVICE(pci, PCIQXLDevice),
-        VMSTATE_STRUCT(vga, PCIQXLDevice, QXL_VER, vmstate_vga_common, VGACommonState),
+        VMSTATE_STRUCT(vga, PCIQXLDevice, 0, vmstate_vga_common, VGACommonState),
         VMSTATE_UINT32(shadow_rom.mode, PCIQXLDevice),
-#if 1 /* wanna zap this */
         VMSTATE_UINT32(num_free_res, PCIQXLDevice),
         VMSTATE_UINT32(last_release_offset, PCIQXLDevice),
-#endif
         VMSTATE_UINT32(mode, PCIQXLDevice),
         VMSTATE_UINT32(ssd.unique, PCIQXLDevice),
-#if 1 /* new stuff */
-        VMSTATE_STRUCT_ARRAY(guest_slots, PCIQXLDevice, NUM_MEMSLOTS, QXL_VER,
-                             qxl_memslot, struct guest_slots),
-        VMSTATE_STRUCT(guest_primary.surface, PCIQXLDevice, QXL_VER,
-                       qxl_surface, QXLSurfaceCreate),
-        VMSTATE_ARRAY(guest_surfaces.cmds, PCIQXLDevice, NUM_SURFACES, QXL_VER,
-                      vmstate_info_uint64, uint64_t),
-        VMSTATE_UINT64(guest_cursor, PCIQXLDevice),
-#endif
+
+        /* spice 0.4 sends/expects them */
+        VMSTATE_VBUFFER_UINT32(vga.vram_ptr, PCIQXLDevice, 0, qxl_test_spice04, 0,
+                               vga.vram_size),
+        VMSTATE_UINT32_TEST(worker_data_size, PCIQXLDevice, qxl_test_spice04),
+        VMSTATE_VBUFFER_UINT32(worker_data, PCIQXLDevice, 0, qxl_test_worker_data, 0,
+                               worker_data_size),
+
         VMSTATE_END_OF_LIST()
-    }
+    },
+    .subsections = (VMStateSubsection[]) {
+        {
+            /* additional spice 0.6 state */
+            .vmsd   = &qxl_vmstate_spice06,
+            .needed = qxl_test_spice06,
+        },{
+            /* end of list */
+        },
+    },
 };
 
 static PCIDeviceInfo qxl_info = {
diff --git a/hw/qxl.h b/hw/qxl.h
index 49231ee..792fe60 100644
--- a/hw/qxl.h
+++ b/hw/qxl.h
@@ -24,6 +24,9 @@ typedef struct PCIQXLDevice {
     int                generation;
     uint32_t           revision;
 
+    int32_t            num_memslots;
+    int32_t            num_surfaces;
+
     struct guest_slots {
         QXLMemSlot     slot;
         void           *ptr;
@@ -74,6 +77,9 @@ typedef struct PCIQXLDevice {
     /* io bar */
     uint32_t           io_base;
 
+    /* spice 0.4 loadvm compatibility */
+    void               *worker_data;
+    uint32_t           worker_data_size;
 } PCIQXLDevice;
 
 #define PANIC_ON(x) if ((x)) {                         \


More information about the Spice-commits mailing list