From 58117ea6206f512a81b70696db43043d2233d071 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 3 Jun 2015 09:27:31 +0200 Subject: [PATCH] Update to v2.3.0 keymap.diff: removing last hunk It only removes spaces, upstream already did that when adding an assertion to it. pve-auth.diff & fairsched.diff: * dropped fairsched and moved vmid code to pve-auth.diff * adapt pve-auth.diff to new qemu option parsing virtio-balloon-fix-query.patch: * merged ram_size -> get_current_ram_size() change backup-modify-job-api.patch * move new bdrv_op_unblock(target) into target guard * fuzz/context fixup * added NULL target checks to new places where necessary (bdrv_op_is_blocked is now used on the target in backup_start) * annotated some hunks with their function * applied same backup_start fixup of qmp_drive_backup to the new qmp_blockdev_backup (introduced in c29c1dd3) disable-efi-enable-pxe-roms.patch: fuzz/context fixup virtio-balloon-dimmfix1.patch: is now upstream virtio-balloon-dimmfix2.patch: is now upstream virtio-balloon-dimmfix3.patch: merged into virtio-balloon-fix-query.patch virtio-scsi_fix_assert.patch: is now upstream backup-add-dir-format.patch, backup-add-pve-monitor-commands.patch, internal-snapshot-async.patch: * Convert bdrv_find to blk_by_name bdrv_find was dropped and the code now uses blk_by_name and blk_bs internal-snapshot-async.patch: * fuzz/context fixups * added missing sysemu/block-backend.h for blk_by_name --- debian/patches/backup-add-dir-format.patch | 4 +- .../backup-add-pve-monitor-commands.patch | 10 +- debian/patches/backup-add-vma-binary.patch | 4 +- debian/patches/backup-modify-job-api.patch | 47 ++++- .../patches/disable-efi-enable-pxe-roms.patch | 8 +- debian/patches/fairsched.diff | 163 ------------------ debian/patches/internal-snapshot-async.patch | 59 ++++--- debian/patches/keymap.diff | 9 - debian/patches/pve-auth.patch | 138 +++++++++------ debian/patches/series | 5 - debian/patches/virtio-balloon-dimmfix1.patch | 93 ---------- debian/patches/virtio-balloon-dimmfix2.patch | 93 ---------- debian/patches/virtio-balloon-dimmfix3.patch | 27 --- debian/patches/virtio-balloon-fix-query.patch | 24 +-- debian/patches/virtio-scsi_fix_assert.patch | 45 ----- 15 files changed, 183 insertions(+), 546 deletions(-) delete mode 100644 debian/patches/fairsched.diff delete mode 100644 debian/patches/virtio-balloon-dimmfix1.patch delete mode 100644 debian/patches/virtio-balloon-dimmfix2.patch delete mode 100644 debian/patches/virtio-balloon-dimmfix3.patch delete mode 100644 debian/patches/virtio-scsi_fix_assert.patch diff --git a/debian/patches/backup-add-dir-format.patch b/debian/patches/backup-add-dir-format.patch index ea87701..3523a48 100644 --- a/debian/patches/backup-add-dir-format.patch +++ b/debian/patches/backup-add-dir-format.patch @@ -47,9 +47,9 @@ Index: new/blockdev.c block_job_cb(bs, ret); @@ -2138,6 +2141,7 @@ - bool has_speed, int64_t speed, Error **errp) { - BlockDriverState *bs; + BlockBackend *blk; + BlockDriverState *bs = NULL; + const char *backup_dir = NULL; Error *local_err = NULL; uuid_t uuid; diff --git a/debian/patches/backup-add-pve-monitor-commands.patch b/debian/patches/backup-add-pve-monitor-commands.patch index 6a2cd61..e58033e 100644 --- a/debian/patches/backup-add-pve-monitor-commands.patch +++ b/debian/patches/backup-add-pve-monitor-commands.patch @@ -10,7 +10,7 @@ Index: new/blockdev.c static const char *const if_name[IF_COUNT] = { [IF_NONE] = "none", -@@ -1954,6 +1955,437 @@ +@@ -1954,6 +1955,439 @@ bdrv_put_ref_bh_schedule(bs); } @@ -196,7 +196,8 @@ Index: new/blockdev.c + bool has_devlist, const char *devlist, + bool has_speed, int64_t speed, Error **errp) +{ -+ BlockDriverState *bs; ++ BlockBackend *blk; ++ BlockDriverState *bs = NULL; + Error *local_err = NULL; + uuid_t uuid; + VmaWriter *vmaw = NULL; @@ -223,8 +224,9 @@ Index: new/blockdev.c + + gchar **d = devs; + while (d && *d) { -+ bs = bdrv_find(*d); -+ if (bs) { ++ blk = blk_by_name(*d); ++ if (blk) { ++ bs = blk_bs(blk); + if (bdrv_is_read_only(bs)) { + error_set(errp, QERR_DEVICE_IS_READ_ONLY, *d); + goto err; diff --git a/debian/patches/backup-add-vma-binary.patch b/debian/patches/backup-add-vma-binary.patch index 366af84..6fbd7ad 100644 --- a/debian/patches/backup-add-vma-binary.patch +++ b/debian/patches/backup-add-vma-binary.patch @@ -26,7 +26,7 @@ Index: new/Makefile =================================================================== --- new.orig/Makefile 2014-11-20 08:12:54.000000000 +0100 +++ new/Makefile 2014-11-20 08:15:12.000000000 +0100 -@@ -152,7 +152,7 @@ +@@ -156,7 +156,7 @@ include $(SRC_PATH)/libcacard/Makefile endif @@ -35,7 +35,7 @@ Index: new/Makefile config-host.h: config-host.h-timestamp config-host.h-timestamp: config-host.mak -@@ -220,6 +220,7 @@ +@@ -224,6 +224,7 @@ qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a qemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a diff --git a/debian/patches/backup-modify-job-api.patch b/debian/patches/backup-modify-job-api.patch index 53aa7be..f5e81a7 100644 --- a/debian/patches/backup-modify-job-api.patch +++ b/debian/patches/backup-modify-job-api.patch @@ -77,18 +77,20 @@ Index: new/block/backup.c bdrv_add_before_write_notifier(bs, &before_write); -@@ -359,7 +373,9 @@ +@@ -359,8 +373,10 @@ hbitmap_free(job->bitmap); - bdrv_iostatus_disable(target); +- bdrv_op_unblock_all(target, job->common.blocker); + if (target) { + bdrv_iostatus_disable(target); ++ bdrv_op_unblock_all(target, job->common.blocker); + } data = g_malloc(sizeof(*data)); data->ret = ret; -@@ -370,13 +386,15 @@ +@@ -370,13 +386,15 @@ for backup_start int64_t speed, MirrorSyncMode sync_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, @@ -104,11 +106,33 @@ Index: new/block/backup.c + assert(target || dump_cb); assert(cb); - if ((on_source_error == BLOCKDEV_ON_ERROR_STOP || -@@ -399,10 +417,12 @@ + if (bs == target) { +@@ -419,7 +437,7 @@ in backup_start return; } +- if (!bdrv_is_inserted(target)) { ++ if (target && !bdrv_is_inserted(target)) { + error_setg(errp, "Device is not inserted: %s", + bdrv_get_device_name(target)); + return; +@@ -429,7 +447,7 @@ in backup_start + return; + } + +- if (bdrv_op_is_blocked(target, BLOCK_OP_TYPE_BACKUP_TARGET, errp)) { ++ if (target && bdrv_op_is_blocked(target, BLOCK_OP_TYPE_BACKUP_TARGET, errp)) { + return; + } + +@@ -397,12 +415,15 @@ in backup_start + return; + } + +- bdrv_op_block_all(target, job->common.blocker); ++ if (target) ++ bdrv_op_block_all(target, job->common.blocker); + + job->dump_cb = dump_cb; job->on_source_error = on_source_error; job->on_target_error = on_target_error; @@ -122,11 +146,20 @@ Index: new/blockdev.c =================================================================== --- new.orig/blockdev.c 2014-11-20 07:55:31.000000000 +0100 +++ new/blockdev.c 2014-11-20 08:48:02.000000000 +0100 -@@ -2223,7 +2223,7 @@ +@@ -2223,7 +2223,7 @@ qmp_drive_backup bdrv_set_aio_context(target_bs, aio_context); backup_start(bs, target_bs, speed, sync, on_source_error, on_target_error, - block_job_cb, bs, &local_err); ++ NULL, block_job_cb, bs, false, &local_err); + if (local_err != NULL) { + bdrv_unref(target_bs); + error_propagate(errp, local_err); +@@ -2284,7 +2284,7 @@ qmp_blockdev_backup + bdrv_ref(target_bs); + bdrv_set_aio_context(target_bs, aio_context); + backup_start(bs, target_bs, speed, sync, on_source_error, on_target_error, +- block_job_cb, bs, &local_err); + NULL, block_job_cb, bs, false, &local_err); if (local_err != NULL) { bdrv_unref(target_bs); @@ -136,8 +169,8 @@ Index: new/include/block/block_int.h --- new.orig/include/block/block_int.h 2014-11-20 07:55:31.000000000 +0100 +++ new/include/block/block_int.h 2014-11-20 08:52:59.000000000 +0100 @@ -57,6 +57,9 @@ - #define BLOCK_OPT_REDUNDANCY "redundancy" - #define BLOCK_OPT_NOCOW "nocow" + + #define BLOCK_PROBE_BUF_SIZE 512 +typedef int BackupDumpFunc(void *opaque, BlockDriverState *bs, + int64_t sector_num, int n_sectors, unsigned char *buf); diff --git a/debian/patches/disable-efi-enable-pxe-roms.patch b/debian/patches/disable-efi-enable-pxe-roms.patch index 9c9d7a2..16c69ce 100644 --- a/debian/patches/disable-efi-enable-pxe-roms.patch +++ b/debian/patches/disable-efi-enable-pxe-roms.patch @@ -4,7 +4,7 @@ Index: new/hw/net/e1000.c +++ new/hw/net/e1000.c 2014-11-20 07:54:14.000000000 +0100 @@ -1606,7 +1606,7 @@ - k->init = pci_e1000_init; + k->realize = pci_e1000_realize; k->exit = pci_e1000_uninit; - k->romfile = "efi-e1000.rom"; + k->romfile = "pxe-e1000.rom"; @@ -17,7 +17,7 @@ Index: new/hw/net/ne2000.c +++ new/hw/net/ne2000.c 2014-11-20 07:54:14.000000000 +0100 @@ -773,7 +773,7 @@ - k->init = pci_ne2000_init; + k->realize = pci_ne2000_realize; k->exit = pci_ne2000_exit; - k->romfile = "efi-ne2k_pci.rom", + k->romfile = "pxe-ne2k_pci.rom", @@ -30,7 +30,7 @@ Index: new/hw/net/pcnet-pci.c +++ new/hw/net/pcnet-pci.c 2014-11-20 07:54:14.000000000 +0100 @@ -367,7 +367,7 @@ - k->init = pci_pcnet_init; + k->realize = pci_pcnet_realize; k->exit = pci_pcnet_uninit; - k->romfile = "efi-pcnet.rom", + k->romfile = "pxe-pcnet.rom", @@ -43,7 +43,7 @@ Index: new/hw/net/rtl8139.c +++ new/hw/net/rtl8139.c 2014-11-20 07:54:14.000000000 +0100 @@ -3562,7 +3562,7 @@ - k->init = pci_rtl8139_init; + k->realize = pci_rtl8139_realize; k->exit = pci_rtl8139_uninit; - k->romfile = "efi-rtl8139.rom"; + k->romfile = "pxe-rtl8139.rom"; diff --git a/debian/patches/fairsched.diff b/debian/patches/fairsched.diff deleted file mode 100644 index e01023f..0000000 --- a/debian/patches/fairsched.diff +++ /dev/null @@ -1,163 +0,0 @@ -Index: new/qemu-options.hx -=================================================================== ---- new.orig/qemu-options.hx 2014-11-20 06:45:06.000000000 +0100 -+++ new/qemu-options.hx 2014-11-20 06:50:44.000000000 +0100 -@@ -386,6 +386,12 @@ - @table @option - ETEXI - -+DEF("id", HAS_ARG, QEMU_OPTION_id, -+ "-id n set the faisched ID\n", QEMU_ARCH_ALL) -+ -+DEF("cpuunits", HAS_ARG, QEMU_OPTION_cpuunits, -+ "-cpuuinits n set fairsched cpu units\n", QEMU_ARCH_ALL) -+ - DEF("fda", HAS_ARG, QEMU_OPTION_fda, - "-fda/-fdb file use 'file' as floppy disk 0/1 image\n", QEMU_ARCH_ALL) - DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "", QEMU_ARCH_ALL) -Index: new/vl.c -=================================================================== ---- new.orig/vl.c 2014-11-20 06:45:06.000000000 +0100 -+++ new/vl.c 2014-11-20 06:50:44.000000000 +0100 -@@ -101,6 +101,8 @@ - #endif - #include "sysemu/qtest.h" - -+#include "vzsyscalls.h" -+ - #include "disas/disas.h" - - -@@ -154,6 +156,7 @@ - CharDriverState *sclp_hds[MAX_SCLP_CONSOLES]; - int win2k_install_hack = 0; - int singlestep = 0; -+int fairsched_id = 0; - int smp_cpus = 1; - int max_cpus = 0; - int smp_cores = 1; -@@ -2738,6 +2741,9 @@ - int main(int argc, char **argv, char **envp) - { - int i; -+ int cpuunits = 0; -+ long int fairsched_id_long = 0; -+ char *ep; - int snapshot, linux_boot; - const char *initrd_filename; - const char *kernel_filename, *kernel_cmdline; -@@ -3560,6 +3566,21 @@ - exit(1); - } - break; -+ case QEMU_OPTION_id: -+ fairsched_id_long = strtol(optarg, &ep, 10); -+ fairsched_id = fairsched_id_long; -+ if (*ep != 0 || fairsched_id_long < 100 || fairsched_id_long > INT_MAX) { -+ fprintf(stderr, "Invalid ID\n"); -+ exit(1); -+ } -+ break; -+ case QEMU_OPTION_cpuunits: -+ cpuunits = atoi(optarg); -+ if (cpuunits < 8 || cpuunits > 500000) { -+ fprintf(stderr, "Invalid value for cpuunits\n"); -+ exit(1); -+ } -+ break; - case QEMU_OPTION_vnc: - #ifdef CONFIG_VNC - display_remote++; -@@ -3844,6 +3865,40 @@ - OBJECT_CLASS(machine_class)))); - object_property_add_child(object_get_root(), "machine", - OBJECT(current_machine), &error_abort); -+ -+ if (cpuunits && !fairsched_id) { -+ fprintf(stderr, "cpuunits specified without -id"); -+ exit(1); -+ } -+ -+ if (fairsched_id && cpuunits) { -+ int ret; -+ int weight = cpuunits ? 500000/cpuunits : 500; -+ pid_t cpid = getpid(); -+ -+ ret = syscall(__NR_fairsched_rmnod, fairsched_id); -+ if (ret == -EBUSY) { -+ fprintf (stderr, "unable to create fairsched node - still in use\n"); -+ exit(1); -+ } -+ -+ ret = syscall(__NR_fairsched_mknod, 0, weight, fairsched_id); -+ if (ret != fairsched_id) { -+ fprintf (stderr, "unable to create fairsched node\n"); -+ exit(1); -+ } -+ -+ ret = syscall(__NR_fairsched_mvpr, cpid, fairsched_id); -+ if (ret != 0) { -+ fprintf (stderr, "unable to move procces to fairsched group"); -+ exit (1); -+ } -+ -+ /* note: we can never remove ourself from the group, so the empty group -+ will exist after we finish -+ */ -+ } -+ - cpu_exec_init_all(); - - if (machine_class->hw_version) { -Index: new/vzsyscalls.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ new/vzsyscalls.h 2014-11-20 06:50:44.000000000 +0100 -@@ -0,0 +1,47 @@ -+/* -+ * Copyright (C) 2000-2008, Parallels, Inc. All rights reserved. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+#ifndef _VZSYSCALLS_H_ -+#define _VZSYSCALLS_H_ -+ -+#include -+ -+#ifdef __x86_64__ -+#define __NR_fairsched_vcpus 499 -+#define __NR_setluid 501 -+#define __NR_setublimit 502 -+#define __NR_fairsched_mknod 504 -+#define __NR_fairsched_rmnod 505 -+#define __NR_fairsched_chwt 506 -+#define __NR_fairsched_mvpr 507 -+#define __NR_fairsched_rate 508 -+#define __NR_ioprio_set 251 -+#elif defined(__i386__) -+#define __NR_fairsched_mknod 500 -+#define __NR_fairsched_rmnod 501 -+#define __NR_fairsched_chwt 502 -+#define __NR_fairsched_mvpr 503 -+#define __NR_fairsched_rate 504 -+#define __NR_fairsched_vcpus 505 -+#define __NR_setluid 511 -+#define __NR_setublimit 512 -+#define __NR_ioprio_set 289 -+#else -+#error "no syscall for this arch" -+#endif -+ -+#endif diff --git a/debian/patches/internal-snapshot-async.patch b/debian/patches/internal-snapshot-async.patch index 52044f0..e6d8a13 100644 --- a/debian/patches/internal-snapshot-async.patch +++ b/debian/patches/internal-snapshot-async.patch @@ -25,19 +25,19 @@ Index: new/Makefile.objs =================================================================== --- new.orig/Makefile.objs 2014-11-20 09:13:01.000000000 +0100 +++ new/Makefile.objs 2014-11-20 09:16:47.000000000 +0100 -@@ -56,6 +56,7 @@ +@@ -53,6 +53,7 @@ common-obj-y += qemu-char.o #aio.o - common-obj-y += block-migration.o - common-obj-y += page_cache.o xbzrle.o + common-obj-y += page_cache.o + common-obj-y += qjson.o +common-obj-y += savevm-async.o - common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o + common-obj-$(CONFIG_SPICE) += spice-qemu-char.o Index: new/block.c =================================================================== --- new.orig/block.c 2014-11-20 09:13:01.000000000 +0100 +++ new/block.c 2014-11-20 09:16:47.000000000 +0100 -@@ -2119,7 +2119,7 @@ +@@ -2202,7 +2202,7 @@ bdrv_set_backing_hd(bs_top, bs_new); } @@ -50,7 +50,7 @@ Index: new/hmp-commands.hx =================================================================== --- new.orig/hmp-commands.hx 2014-11-20 09:13:01.000000000 +0100 +++ new/hmp-commands.hx 2014-11-20 09:16:47.000000000 +0100 -@@ -1799,6 +1799,8 @@ +@@ -1797,6 +1797,8 @@ show current migration capabilities @item info migrate_cache_size show current migration XBZRLE cache size @@ -99,7 +99,7 @@ Index: new/hmp.c =================================================================== --- new.orig/hmp.c 2014-11-20 09:13:01.000000000 +0100 +++ new/hmp.c 2014-11-20 09:16:47.000000000 +0100 -@@ -1849,3 +1849,60 @@ +@@ -1849,6 +1849,63 @@ qapi_free_MemoryDeviceInfoList(info_list); } @@ -160,6 +160,9 @@ Index: new/hmp.c + monitor_printf(mon, "Error: %s\n", info->error); + } +} + + void hmp_qom_list(Monitor *mon, const QDict *qdict) + { Index: new/hmp.h =================================================================== --- new.orig/hmp.h 2014-11-20 09:13:01.000000000 +0100 @@ -180,8 +183,8 @@ Index: new/hmp.h +void hmp_snapshot_drive(Monitor *mon, const QDict *qdict); +void hmp_delete_drive_snapshot(Monitor *mon, const QDict *qdict); +void hmp_savevm_end(Monitor *mon, const QDict *qdict); - void hmp_send_key(Monitor *mon, const QDict *qdict); - void hmp_screen_dump(Monitor *mon, const QDict *qdict); + void hmp_sendkey(Monitor *mon, const QDict *qdict); + void hmp_screendump(Monitor *mon, const QDict *qdict); void hmp_nbd_server_start(Monitor *mon, const QDict *qdict); Index: new/include/block/block.h =================================================================== @@ -201,11 +204,11 @@ Index: new/include/sysemu/sysemu.h +++ new/include/sysemu/sysemu.h 2014-11-20 09:16:47.000000000 +0100 @@ -76,16 +76,17 @@ - void do_savevm(Monitor *mon, const QDict *qdict); + void hmp_savevm(Monitor *mon, const QDict *qdict); int load_vmstate(const char *name); +int load_state_from_blockdev(const char *filename); - void do_delvm(Monitor *mon, const QDict *qdict); - void do_info_snapshots(Monitor *mon, const QDict *qdict); + void hmp_delvm(Monitor *mon, const QDict *qdict); + void hmp_info_snapshots(Monitor *mon, const QDict *qdict); void qemu_announce_self(void); @@ -370,7 +373,7 @@ Index: new/savevm-async.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ new/savevm-async.c 2014-11-20 09:17:48.000000000 +0100 -@@ -0,0 +1,497 @@ +@@ -0,0 +1,503 @@ +#include "qemu-common.h" +#include "qapi/qmp/qerror.h" +#include "sysemu/sysemu.h" @@ -383,6 +386,7 @@ Index: new/savevm-async.c +#include "block/qapi.h" +#include "block/block.h" +#include "qemu/timer.h" ++#include "sysemu/block-backend.h" + +/* #define DEBUG_SAVEVM_STATE */ + @@ -695,6 +699,7 @@ Index: new/savevm-async.c + +void qmp_snapshot_drive(const char *device, const char *name, Error **errp) +{ ++ BlockBackend *blk; + BlockDriverState *bs; + QEMUSnapshotInfo sn1, *sn = &sn1; + int ret; @@ -710,12 +715,13 @@ Index: new/savevm-async.c + return; + } + -+ bs = bdrv_find(device); -+ if (!bs) { ++ blk = blk_by_name(device); ++ if (!blk) { + error_set(errp, QERR_DEVICE_NOT_FOUND, device); + return; + } + ++ bs = blk_bs(blk); + if (!bdrv_is_inserted(bs)) { + error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); + return; @@ -766,17 +772,20 @@ Index: new/savevm-async.c +void qmp_delete_drive_snapshot(const char *device, const char *name, + Error **errp) +{ ++ BlockBackend *blk; + BlockDriverState *bs; + QEMUSnapshotInfo sn1, *sn = &sn1; + Error *local_err = NULL; + + int ret; + -+ bs = bdrv_find(device); -+ if (!bs) { ++ blk = blk_by_name(device); ++ if (!blk) { + error_set(errp, QERR_DEVICE_NOT_FOUND, device); + return; + } ++ ++ bs = blk_bs(blk); + if (bdrv_is_read_only(bs)) { + error_set(errp, QERR_DEVICE_IS_READ_ONLY, device); + return; @@ -895,16 +904,16 @@ Index: new/savevm.c /* @@ -690,7 +691,7 @@ - return ret; + return !machine->suppress_vmdesc; } -void qemu_savevm_state_complete(QEMUFile *f) +int qemu_savevm_state_complete(QEMUFile *f) { - SaveStateEntry *se; - int ret; + QJSON *vmdesc; + int vmdesc_len; @@ -717,7 +718,7 @@ - trace_savevm_section_end(se->idstr, se->section_id); + trace_savevm_section_end(se->idstr, se->section_id, ret); if (ret < 0) { qemu_file_set_error(f, ret); - return; @@ -913,8 +922,8 @@ Index: new/savevm.c } @@ -746,6 +747,7 @@ + object_unref(OBJECT(vmdesc)); - qemu_put_byte(f, QEMU_VM_EOF); qemu_fflush(f); + return qemu_file_get_error(f); } @@ -933,9 +942,9 @@ Index: new/vl.c const char *cpu_model; const char *vga_model = NULL; @@ -3457,6 +3458,9 @@ - case QEMU_OPTION_loadvm: - loadvm = optarg; - break; + case QEMU_OPTION_loadvm: + loadvm = optarg; + break; + case QEMU_OPTION_loadstate: + loadstate = optarg; + break; diff --git a/debian/patches/keymap.diff b/debian/patches/keymap.diff index 1bd17d1..682cb9b 100644 --- a/debian/patches/keymap.diff +++ b/debian/patches/keymap.diff @@ -48,12 +48,3 @@ Index: new/ui/vnc.c trace_vnc_key_event_map(down, sym, keycode, code2name(keycode)); do_key_event(vs, down, keycode, sym); } -@@ -3046,7 +3068,7 @@ - char *vnc_display_local_addr(DisplayState *ds) - { - VncDisplay *vs = vnc_display; -- -+ - return vnc_socket_local_addr("%s:%s", vs->lsock); - } - diff --git a/debian/patches/pve-auth.patch b/debian/patches/pve-auth.patch index 7036c84..0d1d43a 100644 --- a/debian/patches/pve-auth.patch +++ b/debian/patches/pve-auth.patch @@ -1,8 +1,61 @@ +Index: new/qemu-options.hx +=================================================================== +--- new.orig/qemu-options.hx 2014-11-20 06:45:06.000000000 +0100 ++++ new/qemu-options.hx 2014-11-20 06:50:44.000000000 +0100 +@@ -411,6 +411,9 @@ + @table @option + ETEXI + ++DEF("id", HAS_ARG, QEMU_OPTION_id, ++ "-id n set the VMID\n", QEMU_ARCH_ALL) ++ + DEF("fda", HAS_ARG, QEMU_OPTION_fda, + "-fda/-fdb file use 'file' as floppy disk 0/1 image\n", QEMU_ARCH_ALL) + DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "", QEMU_ARCH_ALL) +Index: new/vl.c +=================================================================== +--- new.orig/vl.c 2014-11-20 06:45:06.000000000 +0100 ++++ new/vl.c 2014-11-20 06:50:44.000000000 +0100 +@@ -2730,6 +2730,7 @@ + int main(int argc, char **argv, char **envp) + { + int i; ++ long int vm_id_long = 0; + int snapshot, linux_boot; + const char *initrd_filename; + const char *kernel_filename, *kernel_cmdline; +@@ -3477,6 +3478,14 @@ + exit(1); + } + break; ++ case QEMU_OPTION_id: ++ vm_id_long = strtol(optarg, (char **) &optarg, 10); ++ if (*optarg != 0 || vm_id_long < 100 || vm_id_long > INT_MAX) { ++ fprintf(stderr, "Invalid ID\n"); ++ exit(1); ++ } ++ pve_auth_setup(vm_id_long); ++ break; + case QEMU_OPTION_vnc: + #ifdef CONFIG_VNC + if (vnc_parse_func(optarg) == NULL) { +Index: new/include/ui/console.h +=================================================================== +--- new.orig/include/ui/console.h 2014-11-20 06:45:06.000000000 +0100 ++++ new/include/ui/console.h 2014-11-20 06:50:55.000000000 +0100 +@@ -328,6 +328,7 @@ + void cocoa_display_init(DisplayState *ds, int full_screen); + + /* vnc.c */ ++void pve_auth_setup(int vmid); + void vnc_display_init(const char *id); + void vnc_display_open(const char *id, Error **errp); + void vnc_display_add_client(const char *id, int csock, bool skipauth); Index: new/ui/vnc.c =================================================================== --- new.orig/ui/vnc.c 2014-11-20 06:50:51.000000000 +0100 +++ new/ui/vnc.c 2014-11-20 06:50:55.000000000 +0100 -@@ -46,6 +46,125 @@ +@@ -48,6 +48,125 @@ #include "vnc_keysym.h" #include "d3des.h" @@ -125,32 +178,11 @@ Index: new/ui/vnc.c + return -1; +} + - static VncDisplay *vnc_display; /* needed for info vnc */ + static QTAILQ_HEAD(, VncDisplay) vnc_displays = + QTAILQ_HEAD_INITIALIZER(vnc_displays); - static int vnc_cursor_define(VncState *vs); -@@ -3156,6 +3275,7 @@ - tls = 1; /* Require TLS */ - } else if (strncmp(options, "x509", 4) == 0) { - char *start, *end; -+ tls = 1; /* Require TLS */ - x509 = 1; /* Require x509 certificates */ - if (strncmp(options, "x509verify", 10) == 0) - vs->tls.x509verify = 1; /* ...and verify client certs */ -@@ -3176,8 +3296,10 @@ - } - g_free(path); - } else { -- error_setg(errp, "No certificate path provided"); -- goto fail; -+ if (pve_tls_set_x509_creds_dir(vs) < 0) { -+ error_setg(errp, "No certificate path provided"); -+ goto fail; -+ } +@@ -3393,10 +3512,10 @@ } - #endif - #if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL) -@@ -3250,10 +3372,10 @@ - vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 password auth\n"); - vs->subauth = VNC_AUTH_VENCRYPT_X509VNC; @@ -161,7 +193,23 @@ Index: new/ui/vnc.c + vs->subauth = VNC_AUTH_VENCRYPT_TLSPLAIN; } } else { - #endif /* CONFIG_VNC_TLS */ + VNC_DEBUG("Initializing VNC server with password auth\n"); +@@ -3557,7 +3676,14 @@ + vs->tls.x509verify = true; + } + } +- if (path) { ++ if (path && strcmp(path, "on") == 0) { ++ x509 = true; ++ tls = true; ++ if (pve_tls_set_x509_creds_dir(vs) < 0) { ++ error_setg(errp, "No certificate path provided"); ++ goto fail; ++ } ++ } else if (path) { + x509 = true; + if (vnc_tls_set_x509_creds_dir(vs, path) < 0) { + error_setg(errp, "Failed to find x509 certificates/keys in %s", Index: new/ui/vnc-auth-vencrypt.c =================================================================== --- new.orig/ui/vnc-auth-vencrypt.c 2014-11-20 06:45:06.000000000 +0100 @@ -291,16 +339,16 @@ Index: new/ui/vnc.h =================================================================== --- new.orig/ui/vnc.h 2014-11-20 06:45:06.000000000 +0100 +++ new/ui/vnc.h 2014-11-20 06:50:55.000000000 +0100 -@@ -282,6 +282,8 @@ - char challenge[VNC_AUTH_CHALLENGE_SIZE]; - #ifdef CONFIG_VNC_TLS +@@ -288,6 +288,8 @@ + int auth; int subauth; /* Used by VeNCrypt */ + char challenge[VNC_AUTH_CHALLENGE_SIZE]; + int username_len; + int password_len; + #ifdef CONFIG_VNC_TLS VncStateTLS tls; #endif - #ifdef CONFIG_VNC_SASL -@@ -597,4 +599,6 @@ +@@ -603,4 +605,6 @@ int vnc_zywrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); void vnc_zrle_clear(VncState *vs); @@ -338,7 +386,7 @@ Index: new/ui/vnc-tls.c rc = gnutls_kx_set_priority(s, x509 ? kx_x509 : kx_anon); if (rc != GNUTLS_E_SUCCESS) { return -1; -@@ -462,6 +475,24 @@ +@@ -448,6 +460,24 @@ return 0; } @@ -367,7 +415,7 @@ Index: new/ui/vnc-tls.h =================================================================== --- new.orig/ui/vnc-tls.h 2014-11-20 06:45:06.000000000 +0100 +++ new/ui/vnc-tls.h 2014-11-20 06:50:55.000000000 +0100 -@@ -68,6 +68,8 @@ +@@ -61,6 +61,8 @@ int vnc_tls_validate_certificate(VncState *vs); @@ -376,27 +424,3 @@ Index: new/ui/vnc-tls.h int vnc_tls_set_x509_creds_dir(VncDisplay *vd, const char *path); -Index: new/vl.c -=================================================================== ---- new.orig/vl.c 2014-11-20 06:50:44.000000000 +0100 -+++ new/vl.c 2014-11-20 06:50:55.000000000 +0100 -@@ -3573,6 +3573,7 @@ - fprintf(stderr, "Invalid ID\n"); - exit(1); - } -+ pve_auth_setup(fairsched_id); - break; - case QEMU_OPTION_cpuunits: - cpuunits = atoi(optarg); -Index: new/include/ui/console.h -=================================================================== ---- new.orig/include/ui/console.h 2014-11-20 06:45:06.000000000 +0100 -+++ new/include/ui/console.h 2014-11-20 06:50:55.000000000 +0100 -@@ -327,6 +327,7 @@ - void cocoa_display_init(DisplayState *ds, int full_screen); - - /* vnc.c */ -+void pve_auth_setup(int vmid); - void vnc_display_init(DisplayState *ds); - void vnc_display_open(DisplayState *ds, const char *display, Error **errp); - void vnc_display_add_client(DisplayState *ds, int csock, bool skipauth); diff --git a/debian/patches/series b/debian/patches/series index 5041ded..d2e0ecf 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,6 +1,5 @@ fr-ca-keymap-corrections.diff adjust-path.diff -fairsched.diff keymap.diff pve-auth.patch vencrypt-auth-plain.patch @@ -29,9 +28,5 @@ disable-efi-enable-pxe-roms.patch backup-vma-allow-empty-backups.patch glusterfs-daemonize.patch gluster-backupserver.patch -virtio-balloon-dimmfix1.patch -virtio-balloon-dimmfix2.patch -virtio-balloon-dimmfix3.patch add-qmp-get-link-status.patch -virtio-scsi_fix_assert.patch 0001-friendlier-ai_flag-hints-for-ipv6-hosts.patch diff --git a/debian/patches/virtio-balloon-dimmfix1.patch b/debian/patches/virtio-balloon-dimmfix1.patch deleted file mode 100644 index 3f1e1ad..0000000 --- a/debian/patches/virtio-balloon-dimmfix1.patch +++ /dev/null @@ -1,93 +0,0 @@ -From patchwork Wed Mar 4 19:13:32 2015 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Subject: [PULL, - 2/5] virtio-balloon: Fix balloon not working correctly when hotplug - memory -From: Luiz Capitulino -X-Patchwork-Id: 446384 -Message-Id: <1425496415-6161-3-git-send-email-lcapitulino@redhat.com> -To: peter.maydell@linaro.org -Cc: qemu-devel@nongnu.org -Date: Wed, 4 Mar 2015 14:13:32 -0500 - -From: zhanghailiang - -When do memory balloon, it takes the 'ram_size' as the VM's current ram size, -But 'ram_size' is the startup configured ram size, it does not take into -account the hotplugged memory. - -As a result, the balloon result will be confused. -Steps to reproduce: -(1)Start VM: qemu -m size=1024,slots=4,maxmem=8G -(2)In VM: #free -m : 1024M -(3)qmp balloon 512M -(4)In VM: #free -m : 512M -(5)hotplug pc-dimm 1G -(6)In VM: #free -m : 1512M -(7)qmp balloon 256M -(8)In VM: #free -m :1256M -We expect the VM's available ram size to be 256M after 'qmp balloon 256M' -command, but VM's real available ram size is 1256M. - -For "qmp balloon" is not performance critical code, we use function -'get_current_ram_size' to get VM's current ram size. - -Signed-off-by: zhanghailiang -Signed-off-by: Luiz Capitulino -Signed-off-by: Alexandre Derumier ---- - hw/virtio/virtio-balloon.c | 16 +++++++++------- - 1 file changed, 9 insertions(+), 7 deletions(-) - -diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c -index 14390e1..df3333c 100644 ---- a/hw/virtio/virtio-balloon.c -+++ b/hw/virtio/virtio-balloon.c -@@ -294,10 +294,12 @@ static void virtio_balloon_set_config(VirtIODevice *vdev, - VirtIOBalloon *dev = VIRTIO_BALLOON(vdev); - struct virtio_balloon_config config; - uint32_t oldactual = dev->actual; -+ ram_addr_t vm_ram_size = get_current_ram_size(); -+ - memcpy(&config, config_data, sizeof(struct virtio_balloon_config)); - dev->actual = le32_to_cpu(config.actual); - if (dev->actual != oldactual) { -- qapi_event_send_balloon_change(ram_size - -+ qapi_event_send_balloon_change(vm_ram_size - - ((ram_addr_t) dev->actual << VIRTIO_BALLOON_PFN_SHIFT), - &error_abort); - } -@@ -312,9 +314,8 @@ static uint32_t virtio_balloon_get_features(VirtIODevice *vdev, uint32_t f) - static void virtio_balloon_stat(void *opaque, BalloonInfo *info) - { - VirtIOBalloon *dev = opaque; -- info->actual = ram_size - ((uint64_t) dev->actual << -- VIRTIO_BALLOON_PFN_SHIFT); -- -+ info->actual = get_current_ram_size() - ((uint64_t) dev->actual << -+ VIRTIO_BALLOON_PFN_SHIFT); - info->max_mem = ram_size; - - if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) && -@@ -349,12 +350,13 @@ static void virtio_balloon_to_target(void *opaque, ram_addr_t target) - { - VirtIOBalloon *dev = VIRTIO_BALLOON(opaque); - VirtIODevice *vdev = VIRTIO_DEVICE(dev); -+ ram_addr_t vm_ram_size = get_current_ram_size(); - -- if (target > ram_size) { -- target = ram_size; -+ if (target > vm_ram_size) { -+ target = vm_ram_size; - } - if (target) { -- dev->num_pages = (ram_size - target) >> VIRTIO_BALLOON_PFN_SHIFT; -+ dev->num_pages = (vm_ram_size - target) >> VIRTIO_BALLOON_PFN_SHIFT; - virtio_notify_config(vdev); - } - } --- -1.7.10.4 - diff --git a/debian/patches/virtio-balloon-dimmfix2.patch b/debian/patches/virtio-balloon-dimmfix2.patch deleted file mode 100644 index 782d5a4..0000000 --- a/debian/patches/virtio-balloon-dimmfix2.patch +++ /dev/null @@ -1,93 +0,0 @@ -From patchwork Wed Mar 4 19:13:31 2015 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Subject: [PULL, 1/5] pc-dimm: add a function to calculate VM's current RAM size -From: Luiz Capitulino -X-Patchwork-Id: 446386 -Message-Id: <1425496415-6161-2-git-send-email-lcapitulino@redhat.com> -To: peter.maydell@linaro.org -Cc: qemu-devel@nongnu.org -Date: Wed, 4 Mar 2015 14:13:31 -0500 - -From: zhanghailiang - -The global parameter 'ram_size' does not take into account -the hotplugged memory. - -In some codes, we use 'ram_size' as current VM's real RAM size, -which is not correct. - -Add function 'get_current_ram_size' to calculate VM's current RAM size, -it will enumerate present memory devices and also plus ram_size. - -Signed-off-by: zhanghailiang -Signed-off-by: Luiz Capitulino ---- - hw/mem/pc-dimm.c | 26 ++++++++++++++++++++++++++ - include/exec/cpu-common.h | 1 + - stubs/qmp_pc_dimm_device_list.c | 5 +++++ - 3 files changed, 32 insertions(+) - -diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c -index f27a087..de81b9c 100644 ---- a/hw/mem/pc-dimm.c -+++ b/hw/mem/pc-dimm.c -@@ -100,6 +100,32 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque) - return 0; - } - -+ram_addr_t get_current_ram_size(void) -+{ -+ MemoryDeviceInfoList *info_list = NULL; -+ MemoryDeviceInfoList **prev = &info_list; -+ MemoryDeviceInfoList *info; -+ ram_addr_t size = ram_size; -+ -+ qmp_pc_dimm_device_list(qdev_get_machine(), &prev); -+ for (info = info_list; info; info = info->next) { -+ MemoryDeviceInfo *value = info->value; -+ -+ if (value) { -+ switch (value->kind) { -+ case MEMORY_DEVICE_INFO_KIND_DIMM: -+ size += value->dimm->size; -+ break; -+ default: -+ break; -+ } -+ } -+ } -+ qapi_free_MemoryDeviceInfoList(info_list); -+ -+ return size; -+} -+ - static int pc_dimm_slot2bitmap(Object *obj, void *opaque) - { - unsigned long *bitmap = opaque; -diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h -index 427b851..fcc3162 100644 ---- a/include/exec/cpu-common.h -+++ b/include/exec/cpu-common.h -@@ -52,6 +52,7 @@ typedef uintptr_t ram_addr_t; - #endif - - extern ram_addr_t ram_size; -+ram_addr_t get_current_ram_size(void); - - /* memory API */ - -diff --git a/stubs/qmp_pc_dimm_device_list.c b/stubs/qmp_pc_dimm_device_list.c -index 5cb220c..b584bd8 100644 ---- a/stubs/qmp_pc_dimm_device_list.c -+++ b/stubs/qmp_pc_dimm_device_list.c -@@ -5,3 +5,8 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque) - { - return 0; - } -+ -+ram_addr_t get_current_ram_size(void) -+{ -+ return ram_size; -+} diff --git a/debian/patches/virtio-balloon-dimmfix3.patch b/debian/patches/virtio-balloon-dimmfix3.patch deleted file mode 100644 index a8de329..0000000 --- a/debian/patches/virtio-balloon-dimmfix3.patch +++ /dev/null @@ -1,27 +0,0 @@ -From f818a6aa247b71e8185a3277910ac1cd935432d1 Mon Sep 17 00:00:00 2001 -From: Alexandre Derumier -Date: Mon, 9 Mar 2015 10:18:01 +0100 -Subject: [PATCH] info max_mem : get_current_ram_size - - -Signed-off-by: Alexandre Derumier ---- - hw/virtio/virtio-balloon.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c -index df3333c..7f6da3f 100644 ---- a/hw/virtio/virtio-balloon.c -+++ b/hw/virtio/virtio-balloon.c -@@ -316,7 +316,7 @@ static void virtio_balloon_stat(void *opaque, BalloonInfo *info) - VirtIOBalloon *dev = opaque; - info->actual = get_current_ram_size() - ((uint64_t) dev->actual << - VIRTIO_BALLOON_PFN_SHIFT); -- info->max_mem = ram_size; -+ info->max_mem = get_current_ram_size(); - - if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) && - dev->stats_last_update)) { --- -1.7.10.4 - diff --git a/debian/patches/virtio-balloon-fix-query.patch b/debian/patches/virtio-balloon-fix-query.patch index 2220073..236a624 100644 --- a/debian/patches/virtio-balloon-fix-query.patch +++ b/debian/patches/virtio-balloon-fix-query.patch @@ -2,7 +2,7 @@ Index: new/hmp.c =================================================================== --- new.orig/hmp.c 2014-11-20 06:45:05.000000000 +0100 +++ new/hmp.c 2014-11-20 07:26:23.000000000 +0100 -@@ -539,7 +539,35 @@ +@@ -635,7 +635,35 @@ return; } @@ -43,16 +43,21 @@ Index: new/hw/virtio/virtio-balloon.c =================================================================== --- new.orig/hw/virtio/virtio-balloon.c 2014-11-20 06:45:06.000000000 +0100 +++ new/hw/virtio/virtio-balloon.c 2014-11-20 07:26:23.000000000 +0100 -@@ -314,6 +314,35 @@ +@@ -319,8 +319,37 @@ + static void virtio_balloon_stat(void *opaque, BalloonInfo *info) + { VirtIOBalloon *dev = opaque; - info->actual = ram_size - ((uint64_t) dev->actual << - VIRTIO_BALLOON_PFN_SHIFT); +- info->actual = get_current_ram_size() - ((uint64_t) dev->actual << +- VIRTIO_BALLOON_PFN_SHIFT); ++ ram_addr_t ram_size = get_current_ram_size(); ++ info->actual = ram_size - ((uint64_t) dev->actual << ++ VIRTIO_BALLOON_PFN_SHIFT); + + info->max_mem = ram_size; + + if (!(balloon_stats_enabled(dev) && balloon_stats_supported(dev) && -+ dev->stats_last_update)) { -+ return; ++ dev->stats_last_update)) { ++ return; + } + + info->last_update = dev->stats_last_update; @@ -75,7 +80,6 @@ Index: new/hw/virtio/virtio-balloon.c + + info->total_mem = dev->stats[VIRTIO_BALLOON_S_MEMTOT]; + info->has_total_mem = info->total_mem >= 0 ? true : false; -+ } static void virtio_balloon_to_target(void *opaque, ram_addr_t target) @@ -83,7 +87,7 @@ Index: new/qapi-schema.json =================================================================== --- new.orig/qapi-schema.json 2014-11-20 06:45:06.000000000 +0100 +++ new/qapi-schema.json 2014-11-20 07:26:23.000000000 +0100 -@@ -888,15 +888,34 @@ +@@ -983,15 +983,34 @@ ## # @BalloonInfo: @@ -125,7 +129,7 @@ Index: new/qmp-commands.hx =================================================================== --- new.orig/qmp-commands.hx 2014-11-20 06:45:06.000000000 +0100 +++ new/qmp-commands.hx 2014-11-20 07:26:23.000000000 +0100 -@@ -3234,6 +3234,13 @@ +@@ -3329,6 +3329,13 @@ json-object will be returned containing the following data: - "actual": current balloon value in bytes (json-int) @@ -139,7 +143,7 @@ Index: new/qmp-commands.hx Example: -@@ -3241,6 +3248,12 @@ +@@ -3336,6 +3344,12 @@ <- { "return":{ "actual":1073741824, diff --git a/debian/patches/virtio-scsi_fix_assert.patch b/debian/patches/virtio-scsi_fix_assert.patch deleted file mode 100644 index 4e4ccce..0000000 --- a/debian/patches/virtio-scsi_fix_assert.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 3ad2a905f10a4a9e7c7a385d64032a291eb6892b Mon Sep 17 00:00:00 2001 -From: Fam Zheng -Date: Fri, 13 Mar 2015 15:55:54 +0800 -Subject: [PATCH] virtio-scsi: Fix assert in virtio_scsi_push_event - -Hotplugging a scsi-disk may trigger the assertion in qemu_sgl_concat. - - qemu-system-x86_64: qemu/hw/scsi/virtio-scsi.c:115: qemu_sgl_concat: - Assertion `skip == 0' failed. - -This is introduced by commit 55783a55 (virtio-scsi: work around bug in -old BIOSes) which didn't check out_num when accessing out_sg[0].iov_len -(the same to in sg). For virtio_scsi_push_event, looking into out_sg -doesn't make sense because 0 req_size is intended. - -Cc: qemu-stable@nongnu.org -[Cc'ing qemu-stable because 55783a55 did it too] -Signed-off-by: Fam Zheng -Signed-off-by: Stefan Priebe ---- - hw/scsi/virtio-scsi.c | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c -index a44c410..810c377 100644 ---- a/hw/scsi/virtio-scsi.c -+++ b/hw/scsi/virtio-scsi.c -@@ -145,8 +145,12 @@ static int virtio_scsi_parse_req(VirtIOSCSIReq *req, - * TODO: always disable this workaround for virtio 1.0 devices. - */ - if ((vdev->guest_features & (1 << VIRTIO_F_ANY_LAYOUT)) == 0) { -- req_size = req->elem.out_sg[0].iov_len; -- resp_size = req->elem.in_sg[0].iov_len; -+ if (req->elem.out_num) { -+ req_size = req->elem.out_sg[0].iov_len; -+ } -+ if (req->elem.in_num) { -+ resp_size = req->elem.in_sg[0].iov_len; -+ } - } - - out_size = qemu_sgl_concat(req, req->elem.out_sg, --- -1.7.10.4 - -- 2.39.2