This is done for two reasons: - we are getting very close to 64 flags which is the maximum we can use with unsigned long long - by using LL constants in enum we already violates C99 constraint that enum values have to fit into int --- src/qemu/qemu_capabilities.c | 190 ++++++++++++++++++++++++------------------ src/qemu/qemu_capabilities.h | 143 +++++++++++++++++--------------- src/qemu/qemu_command.c | 54 ++++++------ src/qemu/qemu_command.h | 30 ++++---- src/qemu/qemu_driver.c | 32 +++++-- src/qemu/qemu_hotplug.c | 34 ++++---- src/qemu/qemu_hotplug.h | 32 ++++---- 7 files changed, 281 insertions(+), 234 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 55f670b..4f63823 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -366,7 +366,7 @@ error: int qemuCapsProbeCPUModels(const char *qemu, - unsigned long long qemuCaps, + virBitmapPtr qemuCaps, const char *arch, unsigned int *count, const char ***cpus) @@ -431,7 +431,7 @@ qemuCapsInitGuest(virCapsPtr caps, int nmachines = 0; struct stat st; unsigned int ncpus; - unsigned long long qemuCaps; + virBitmapPtr qemuCaps = NULL; int ret = -1; /* Check for existance of base emulator, or alternate base @@ -542,7 +542,7 @@ qemuCapsInitGuest(virCapsPtr caps, guest->arch.defaultInfo.emulator_mtime = binary_mtime; if (caps->host.cpu && - qemuCapsProbeCPUModels(binary, 0, info->arch, &ncpus, NULL) == 0 && + qemuCapsProbeCPUModels(binary, NULL, info->arch, &ncpus, NULL) == 0 && ncpus > 0 && !virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0)) goto error; @@ -637,6 +637,7 @@ cleanup: VIR_FREE(binary); VIR_FREE(kvmbin); } + qemuCapsFree(qemuCaps); return ret; @@ -770,129 +771,129 @@ virCapsPtr qemuCapsInit(virCapsPtr old_caps) } -static unsigned long long +static void qemuCapsComputeCmdFlags(const char *help, unsigned int version, unsigned int is_kvm, - unsigned int kvm_version) + unsigned int kvm_version, + virBitmapPtr flags) { - unsigned long long flags = 0; const char *p; if (strstr(help, "-no-kqemu")) - qemuCapsSet(&flags, QEMU_CAPS_KQEMU); + qemuCapsSet(flags, QEMU_CAPS_KQEMU); if (strstr(help, "-enable-kqemu")) - qemuCapsSet(&flags, QEMU_CAPS_ENABLE_KQEMU); + qemuCapsSet(flags, QEMU_CAPS_ENABLE_KQEMU); if (strstr(help, "-no-kvm")) - qemuCapsSet(&flags, QEMU_CAPS_KVM); + qemuCapsSet(flags, QEMU_CAPS_KVM); if (strstr(help, "-enable-kvm")) - qemuCapsSet(&flags, QEMU_CAPS_ENABLE_KVM); + qemuCapsSet(flags, QEMU_CAPS_ENABLE_KVM); if (strstr(help, "-no-reboot")) - qemuCapsSet(&flags, QEMU_CAPS_NO_REBOOT); + qemuCapsSet(flags, QEMU_CAPS_NO_REBOOT); if (strstr(help, "-name")) { - qemuCapsSet(&flags, QEMU_CAPS_NAME); + qemuCapsSet(flags, QEMU_CAPS_NAME); if (strstr(help, ",process=")) - qemuCapsSet(&flags, QEMU_CAPS_NAME_PROCESS); + qemuCapsSet(flags, QEMU_CAPS_NAME_PROCESS); } if (strstr(help, "-uuid")) - qemuCapsSet(&flags, QEMU_CAPS_UUID); + qemuCapsSet(flags, QEMU_CAPS_UUID); if (strstr(help, "-xen-domid")) - qemuCapsSet(&flags, QEMU_CAPS_XEN_DOMID); + qemuCapsSet(flags, QEMU_CAPS_XEN_DOMID); else if (strstr(help, "-domid")) - qemuCapsSet(&flags, QEMU_CAPS_DOMID); + qemuCapsSet(flags, QEMU_CAPS_DOMID); if (strstr(help, "-drive")) { - qemuCapsSet(&flags, QEMU_CAPS_DRIVE); + qemuCapsSet(flags, QEMU_CAPS_DRIVE); if (strstr(help, "cache=") && !strstr(help, "cache=on|off")) - qemuCapsSet(&flags, QEMU_CAPS_DRIVE_CACHE_V2); + qemuCapsSet(flags, QEMU_CAPS_DRIVE_CACHE_V2); if (strstr(help, "format=")) - qemuCapsSet(&flags, QEMU_CAPS_DRIVE_FORMAT); + qemuCapsSet(flags, QEMU_CAPS_DRIVE_FORMAT); if (strstr(help, "readonly=")) - qemuCapsSet(&flags, QEMU_CAPS_DRIVE_READONLY); + qemuCapsSet(flags, QEMU_CAPS_DRIVE_READONLY); if (strstr(help, "aio=threads|native")) - qemuCapsSet(&flags, QEMU_CAPS_DRIVE_AIO); + qemuCapsSet(flags, QEMU_CAPS_DRIVE_AIO); } if ((p = strstr(help, "-vga")) && !strstr(help, "-std-vga")) { const char *nl = strstr(p, "\n"); - qemuCapsSet(&flags, QEMU_CAPS_VGA); + qemuCapsSet(flags, QEMU_CAPS_VGA); if (strstr(p, "|qxl")) - qemuCapsSet(&flags, QEMU_CAPS_VGA_QXL); + qemuCapsSet(flags, QEMU_CAPS_VGA_QXL); if ((p = strstr(p, "|none")) && p < nl) - qemuCapsSet(&flags, QEMU_CAPS_VGA_NONE); + qemuCapsSet(flags, QEMU_CAPS_VGA_NONE); } if (strstr(help, "-spice")) - qemuCapsSet(&flags, QEMU_CAPS_SPICE); + qemuCapsSet(flags, QEMU_CAPS_SPICE); if (strstr(help, "boot=on")) - qemuCapsSet(&flags, QEMU_CAPS_DRIVE_BOOT); + qemuCapsSet(flags, QEMU_CAPS_DRIVE_BOOT); if (strstr(help, "serial=s")) - qemuCapsSet(&flags, QEMU_CAPS_DRIVE_SERIAL); + qemuCapsSet(flags, QEMU_CAPS_DRIVE_SERIAL); if (strstr(help, "-pcidevice")) - qemuCapsSet(&flags, QEMU_CAPS_PCIDEVICE); + qemuCapsSet(flags, QEMU_CAPS_PCIDEVICE); if (strstr(help, "-mem-path")) - qemuCapsSet(&flags, QEMU_CAPS_MEM_PATH); + qemuCapsSet(flags, QEMU_CAPS_MEM_PATH); if (strstr(help, "-chardev")) { - qemuCapsSet(&flags, QEMU_CAPS_CHARDEV); + qemuCapsSet(flags, QEMU_CAPS_CHARDEV); if (strstr(help, "-chardev spicevmc")) - qemuCapsSet(&flags, QEMU_CAPS_CHARDEV_SPICEVMC); + qemuCapsSet(flags, QEMU_CAPS_CHARDEV_SPICEVMC); } if (strstr(help, "-balloon")) - qemuCapsSet(&flags, QEMU_CAPS_BALLOON); + qemuCapsSet(flags, QEMU_CAPS_BALLOON); if (strstr(help, "-device")) { - qemuCapsSet(&flags, QEMU_CAPS_DEVICE); + qemuCapsSet(flags, QEMU_CAPS_DEVICE); /* * When -device was introduced, qemu already supported drive's * readonly option but didn't advertise that. */ - qemuCapsSet(&flags, QEMU_CAPS_DRIVE_READONLY); + qemuCapsSet(flags, QEMU_CAPS_DRIVE_READONLY); } if (strstr(help, "-nodefconfig")) - qemuCapsSet(&flags, QEMU_CAPS_NODEFCONFIG); + qemuCapsSet(flags, QEMU_CAPS_NODEFCONFIG); /* The trailing ' ' is important to avoid a bogus match */ if (strstr(help, "-rtc ")) - qemuCapsSet(&flags, QEMU_CAPS_RTC); + qemuCapsSet(flags, QEMU_CAPS_RTC); /* to wit */ if (strstr(help, "-rtc-td-hack")) - qemuCapsSet(&flags, QEMU_CAPS_RTC_TD_HACK); + qemuCapsSet(flags, QEMU_CAPS_RTC_TD_HACK); if (strstr(help, "-no-hpet")) - qemuCapsSet(&flags, QEMU_CAPS_NO_HPET); + qemuCapsSet(flags, QEMU_CAPS_NO_HPET); if (strstr(help, "-no-kvm-pit-reinjection")) - qemuCapsSet(&flags, QEMU_CAPS_NO_KVM_PIT); + qemuCapsSet(flags, QEMU_CAPS_NO_KVM_PIT); if (strstr(help, "-tdf")) - qemuCapsSet(&flags, QEMU_CAPS_TDF); + qemuCapsSet(flags, QEMU_CAPS_TDF); if (strstr(help, "-enable-nesting")) - qemuCapsSet(&flags, QEMU_CAPS_NESTING); + qemuCapsSet(flags, QEMU_CAPS_NESTING); if (strstr(help, ",menu=on")) - qemuCapsSet(&flags, QEMU_CAPS_BOOT_MENU); + qemuCapsSet(flags, QEMU_CAPS_BOOT_MENU); if (strstr(help, "-fsdev")) - qemuCapsSet(&flags, QEMU_CAPS_FSDEV); + qemuCapsSet(flags, QEMU_CAPS_FSDEV); if (strstr(help, "-smbios type")) - qemuCapsSet(&flags, QEMU_CAPS_SMBIOS_TYPE); + qemuCapsSet(flags, QEMU_CAPS_SMBIOS_TYPE); if (strstr(help, "-netdev")) { /* Disable -netdev on 0.12 since although it exists, * the corresponding netdev_add/remove monitor commands * do not, and we need them to be able todo hotplug */ if (version >= 13000) - qemuCapsSet(&flags, QEMU_CAPS_NETDEV); + qemuCapsSet(flags, QEMU_CAPS_NETDEV); } if (strstr(help, "-sdl")) - qemuCapsSet(&flags, QEMU_CAPS_SDL); + qemuCapsSet(flags, QEMU_CAPS_SDL); if (strstr(help, "cores=") && strstr(help, "threads=") && strstr(help, "sockets=")) - qemuCapsSet(&flags, QEMU_CAPS_SMP_TOPOLOGY); + qemuCapsSet(flags, QEMU_CAPS_SMP_TOPOLOGY); if (version >= 9000) - qemuCapsSet(&flags, QEMU_CAPS_VNC_COLON); + qemuCapsSet(flags, QEMU_CAPS_VNC_COLON); if (is_kvm && (version >= 10000 || kvm_version >= 74)) - qemuCapsSet(&flags, QEMU_CAPS_VNET_HDR); + qemuCapsSet(flags, QEMU_CAPS_VNET_HDR); if (is_kvm && strstr(help, ",vhost=")) { - qemuCapsSet(&flags, QEMU_CAPS_VNET_HOST); + qemuCapsSet(flags, QEMU_CAPS_VNET_HOST); } /* @@ -908,22 +909,22 @@ qemuCapsComputeCmdFlags(const char *help, * while waiting for data, so pretend it doesn't exist */ if (version >= 10000) { - qemuCapsSet(&flags, QEMU_CAPS_MIGRATE_QEMU_TCP); - qemuCapsSet(&flags, QEMU_CAPS_MIGRATE_QEMU_EXEC); + qemuCapsSet(flags, QEMU_CAPS_MIGRATE_QEMU_TCP); + qemuCapsSet(flags, QEMU_CAPS_MIGRATE_QEMU_EXEC); if (version >= 12000) { - qemuCapsSet(&flags, QEMU_CAPS_MIGRATE_QEMU_UNIX); - qemuCapsSet(&flags, QEMU_CAPS_MIGRATE_QEMU_FD); + qemuCapsSet(flags, QEMU_CAPS_MIGRATE_QEMU_UNIX); + qemuCapsSet(flags, QEMU_CAPS_MIGRATE_QEMU_FD); } } else if (kvm_version >= 79) { - qemuCapsSet(&flags, QEMU_CAPS_MIGRATE_QEMU_TCP); + qemuCapsSet(flags, QEMU_CAPS_MIGRATE_QEMU_TCP); if (kvm_version >= 80) - qemuCapsSet(&flags, QEMU_CAPS_MIGRATE_QEMU_EXEC); + qemuCapsSet(flags, QEMU_CAPS_MIGRATE_QEMU_EXEC); } else if (kvm_version > 0) { - qemuCapsSet(&flags, QEMU_CAPS_MIGRATE_KVM_STDIO); + qemuCapsSet(flags, QEMU_CAPS_MIGRATE_KVM_STDIO); } if (version >= 10000) - qemuCapsSet(&flags, QEMU_CAPS_0_10); + qemuCapsSet(flags, QEMU_CAPS_0_10); /* While JSON mode was available in 0.12.0, it was too * incomplete to contemplate using. The 0.13.0 release @@ -932,9 +933,7 @@ qemuCapsComputeCmdFlags(const char *help, * the downside. */ if (version >= 13000) - qemuCapsSet(&flags, QEMU_CAPS_MONITOR_JSON); - - return flags; + qemuCapsSet(flags, QEMU_CAPS_MONITOR_JSON); } /* We parse the output of 'qemu -help' to get the QEMU @@ -963,15 +962,16 @@ qemuCapsComputeCmdFlags(const char *help, int qemuCapsParseHelpStr(const char *qemu, const char *help, - unsigned long long *flags, + virBitmapPtr flags, unsigned int *version, unsigned int *is_kvm, unsigned int *kvm_version) { unsigned major, minor, micro; const char *p = help; + char *strflags; - *flags = *version = *is_kvm = *kvm_version = 0; + *version = *is_kvm = *kvm_version = 0; if (STRPREFIX(p, QEMU_VERSION_STR_1)) p += strlen(QEMU_VERSION_STR_1); @@ -1018,10 +1018,17 @@ int qemuCapsParseHelpStr(const char *qemu, *version = (major * 1000 * 1000) + (minor * 1000) + micro; - *flags = qemuCapsComputeCmdFlags(help, *version, *is_kvm, *kvm_version); + qemuCapsComputeCmdFlags(help, *version, *is_kvm, *kvm_version, flags); + + if (!(strflags = virBitmapString(flags))) { + virReportOOMError(); + return -1; + } + + VIR_DEBUG("Version %u.%u.%u, cooked version %u, flags %s", + major, minor, micro, *version, strflags); + VIR_FREE(strflags); - VIR_DEBUG("Version %u.%u.%u, cooked version %u, flags 0x%llx", - major, minor, micro, *version, *flags); if (*kvm_version) VIR_DEBUG("KVM version %d detected", *kvm_version); else if (*is_kvm) @@ -1045,7 +1052,7 @@ fail: static int qemuCapsExtractDeviceStr(const char *qemu, - unsigned long long *flags) + virBitmapPtr flags) { char *output = NULL; virCommandPtr cmd; @@ -1082,7 +1089,7 @@ cleanup: int -qemuCapsParseDeviceStr(const char *str, unsigned long long *flags) +qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags) { /* Which devices exist. */ if (strstr(str, "name \"hda-duplex\"")) @@ -1092,7 +1099,7 @@ qemuCapsParseDeviceStr(const char *str, unsigned long long *flags) if (strstr(str, "name \"ccid-card-passthru\"")) qemuCapsSet(flags, QEMU_CAPS_CCID_PASSTHRU); /* Prefer -chardev spicevmc (detected earlier) over -device spicevmc */ - if (!qemuCapsGet(*flags, QEMU_CAPS_CHARDEV_SPICEVMC) && + if (!qemuCapsGet(flags, QEMU_CAPS_CHARDEV_SPICEVMC) && strstr(str, "name \"spicevmc\"")) qemuCapsSet(flags, QEMU_CAPS_DEVICE_SPICEVMC); @@ -1110,16 +1117,16 @@ qemuCapsParseDeviceStr(const char *str, unsigned long long *flags) int qemuCapsExtractVersionInfo(const char *qemu, unsigned int *retversion, - unsigned long long *retflags) + virBitmapPtr *retflags) { int ret = -1; unsigned int version, is_kvm, kvm_version; - unsigned long long flags = 0; + virBitmapPtr flags = NULL; char *help = NULL; virCommandPtr cmd; if (retflags) - *retflags = 0; + *retflags = NULL; if (retversion) *retversion = 0; @@ -1140,7 +1147,8 @@ int qemuCapsExtractVersionInfo(const char *qemu, if (virCommandRun(cmd, NULL) < 0) goto cleanup; - if (qemuCapsParseHelpStr(qemu, help, &flags, + if (!(flags = qemuCapsNew()) || + qemuCapsParseHelpStr(qemu, help, flags, &version, &is_kvm, &kvm_version) == -1) goto cleanup; @@ -1148,19 +1156,22 @@ int qemuCapsExtractVersionInfo(const char *qemu, * understands the 0.13.0+ notion of "-device driver,". */ if (qemuCapsGet(flags, QEMU_CAPS_DEVICE) && strstr(help, "-device driver,?") && - qemuCapsExtractDeviceStr(qemu, &flags) < 0) + qemuCapsExtractDeviceStr(qemu, flags) < 0) goto cleanup; if (retversion) *retversion = version; - if (retflags) + if (retflags) { *retflags = flags; + flags = NULL; + } ret = 0; cleanup: VIR_FREE(help); virCommandFree(cmd); + qemuCapsFree(flags); return ret; } @@ -1213,25 +1224,42 @@ int qemuCapsExtractVersion(virCapsPtr caps, } +virBitmapPtr +qemuCapsNew(void) +{ + virBitmapPtr caps; + + if (!(caps = virBitmapAlloc(QEMU_CAPS_LAST))) + virReportOOMError(); + + return caps; +} + + void -qemuCapsSet(unsigned long long *caps, +qemuCapsSet(virBitmapPtr caps, enum qemuCapsFlags flag) { - *caps |= flag; + ignore_value(virBitmapSetBit(caps, flag)); } void -qemuCapsClear(unsigned long long *caps, +qemuCapsClear(virBitmapPtr caps, enum qemuCapsFlags flag) { - *caps &= ~flag; + ignore_value(virBitmapClearBit(caps, flag)); } bool -qemuCapsGet(unsigned long long caps, +qemuCapsGet(virBitmapPtr caps, enum qemuCapsFlags flag) { - return !!(caps & flag); + bool b; + + if (!caps || virBitmapGetBit(caps, flag, &b) < 0) + return false; + else + return b; } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index f53e5da..193f23d 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -24,83 +24,90 @@ #ifndef __QEMU_CAPABILITIES_H__ # define __QEMU_CAPABILITIES_H__ +# include "bitmap.h" # include "capabilities.h" /* Internal flags to keep track of qemu command line capabilities */ enum qemuCapsFlags { - QEMU_CAPS_KQEMU = (1 << 0), /* Whether KQEMU is compiled in */ - QEMU_CAPS_VNC_COLON = (1 << 1), /* Does the VNC take just port, or address + display */ - QEMU_CAPS_NO_REBOOT = (1 << 2), /* Is the -no-reboot flag available */ - QEMU_CAPS_DRIVE = (1 << 3), /* Is the new -drive arg available */ - QEMU_CAPS_DRIVE_BOOT = (1 << 4), /* Does -drive support boot=on */ - QEMU_CAPS_NAME = (1 << 5), /* Is the -name flag available */ - QEMU_CAPS_UUID = (1 << 6), /* Is the -uuid flag available */ - QEMU_CAPS_DOMID = (1 << 7), /* Xenner only, special -domid flag available */ - QEMU_CAPS_VNET_HDR = (1 << 8), - QEMU_CAPS_MIGRATE_KVM_STDIO = (1 << 9), /* Original migration code from KVM. Also had tcp, but we can't use that - * since it had a design bug blocking the entire monitor console */ - QEMU_CAPS_MIGRATE_QEMU_TCP = (1 << 10), /* New migration syntax after merge to QEMU with TCP transport */ - QEMU_CAPS_MIGRATE_QEMU_EXEC = (1 << 11), /* New migration syntax after merge to QEMU with EXEC transport */ - QEMU_CAPS_DRIVE_CACHE_V2 = (1 << 12), /* Is the cache= flag wanting new v2 values */ - QEMU_CAPS_KVM = (1 << 13), /* Whether KVM is compiled in */ - QEMU_CAPS_DRIVE_FORMAT = (1 << 14), /* Is -drive format= avail */ - QEMU_CAPS_VGA = (1 << 15), /* Is -vga avail */ + QEMU_CAPS_KQEMU, /* Whether KQEMU is compiled in */ + QEMU_CAPS_VNC_COLON, /* Does the VNC take just port, or address + display */ + QEMU_CAPS_NO_REBOOT, /* Is the -no-reboot flag available */ + QEMU_CAPS_DRIVE, /* Is the new -drive arg available */ + QEMU_CAPS_DRIVE_BOOT, /* Does -drive support boot=on */ + QEMU_CAPS_NAME, /* Is the -name flag available */ + QEMU_CAPS_UUID, /* Is the -uuid flag available */ + QEMU_CAPS_DOMID, /* Xenner only, special -domid flag available */ + QEMU_CAPS_VNET_HDR, + QEMU_CAPS_MIGRATE_KVM_STDIO, /* Original migration code from KVM. Also had tcp, but we can't use that + * since it had a design bug blocking the entire monitor console */ + QEMU_CAPS_MIGRATE_QEMU_TCP, /* New migration syntax after merge to QEMU with TCP transport */ + QEMU_CAPS_MIGRATE_QEMU_EXEC, /* New migration syntax after merge to QEMU with EXEC transport */ + QEMU_CAPS_DRIVE_CACHE_V2, /* Is the cache= flag wanting new v2 values */ + QEMU_CAPS_KVM, /* Whether KVM is compiled in */ + QEMU_CAPS_DRIVE_FORMAT, /* Is -drive format= avail */ + QEMU_CAPS_VGA, /* Is -vga avail */ /* features added in qemu-0.10.0 or later */ - QEMU_CAPS_0_10 = (1 << 16), + QEMU_CAPS_0_10, QEMU_CAPS_NET_NAME = QEMU_CAPS_0_10, /* -net ...,name=str */ QEMU_CAPS_HOST_NET_ADD = QEMU_CAPS_0_10, /* host_net_add monitor command */ - QEMU_CAPS_PCIDEVICE = (1 << 17), /* PCI device assignment only supported by qemu-kvm */ - QEMU_CAPS_MEM_PATH = (1 << 18), /* mmap'ped guest backing supported */ - QEMU_CAPS_DRIVE_SERIAL = (1 << 19), /* -driver serial= available */ - QEMU_CAPS_XEN_DOMID = (1 << 20), /* -xen-domid (new style xen integration) */ - QEMU_CAPS_MIGRATE_QEMU_UNIX = (1 << 21), /* Does qemu support unix domain sockets for migration? */ - QEMU_CAPS_CHARDEV = (1 << 22), /* Is the new -chardev arg available */ - QEMU_CAPS_ENABLE_KVM = (1 << 23), /* Is the -enable-kvm flag available to "enable KVM full virtualization support" */ - QEMU_CAPS_MONITOR_JSON = (1 << 24), /* JSON mode for monitor */ - QEMU_CAPS_BALLOON = (1 << 25), /* -balloon available */ - QEMU_CAPS_DEVICE = (1 << 26), /* Is the new -device arg available */ - QEMU_CAPS_SDL = (1 << 27), /* Is the new -sdl arg available */ - QEMU_CAPS_SMP_TOPOLOGY = (1 << 28), /* Is sockets=s,cores=c,threads=t available for -smp? */ - QEMU_CAPS_NETDEV = (1 << 29), /* The -netdev flag & netdev_add/remove monitor commands */ - QEMU_CAPS_RTC = (1 << 30), /* The -rtc flag for clock options */ - QEMU_CAPS_VNET_HOST = (1LL << 31), /* vnet-host support is available in qemu */ - QEMU_CAPS_RTC_TD_HACK = (1LL << 32), /* -rtc-td-hack available */ - QEMU_CAPS_NO_HPET = (1LL << 33), /* -no-hpet flag is supported */ - QEMU_CAPS_NO_KVM_PIT = (1LL << 34), /* -no-kvm-pit-reinjection supported */ - QEMU_CAPS_TDF = (1LL << 35), /* -tdf flag (user-mode pit catchup) */ - QEMU_CAPS_PCI_CONFIGFD = (1LL << 36), /* pci-assign.configfd */ - QEMU_CAPS_NODEFCONFIG = (1LL << 37), /* -nodefconfig */ - QEMU_CAPS_BOOT_MENU = (1LL << 38), /* -boot menu=on support */ - QEMU_CAPS_ENABLE_KQEMU = (1LL << 39), /* -enable-kqemu flag */ - QEMU_CAPS_FSDEV = (1LL << 40), /* -fstype filesystem passthrough */ - QEMU_CAPS_NESTING = (1LL << 41), /* -enable-nesting (SVM/VMX) */ - QEMU_CAPS_NAME_PROCESS = (1LL << 42), /* Is -name process= available */ - QEMU_CAPS_DRIVE_READONLY= (1LL << 43), /* -drive readonly=on|off */ - QEMU_CAPS_SMBIOS_TYPE = (1LL << 44), /* Is -smbios type= available */ - QEMU_CAPS_VGA_QXL = (1LL << 45), /* The 'qxl' arg for '-vga' */ - QEMU_CAPS_SPICE = (1LL << 46), /* Is -spice avail */ - QEMU_CAPS_VGA_NONE = (1LL << 47), /* The 'none' arg for '-vga' */ - QEMU_CAPS_MIGRATE_QEMU_FD = (1LL << 48), /* -incoming fd:n */ - QEMU_CAPS_BOOTINDEX = (1LL << 49), /* -device bootindex property */ - QEMU_CAPS_HDA_DUPLEX = (1LL << 50), /* -device hda-duplex */ - QEMU_CAPS_DRIVE_AIO = (1LL << 51), /* -drive aio= supported */ - QEMU_CAPS_PCI_MULTIBUS = (1LL << 52), /* bus=pci.0 vs bus=pci */ - QEMU_CAPS_PCI_BOOTINDEX = (1LL << 53), /* pci-assign.bootindex */ - QEMU_CAPS_CCID_EMULATED = (1LL << 54), /* -device ccid-card-emulated */ - QEMU_CAPS_CCID_PASSTHRU = (1LL << 55), /* -device ccid-card-passthru */ - QEMU_CAPS_CHARDEV_SPICEVMC = (1LL << 56), /* newer -chardev spicevmc */ - QEMU_CAPS_DEVICE_SPICEVMC = (1LL << 57), /* older -device spicevmc*/ + QEMU_CAPS_PCIDEVICE, /* PCI device assignment only supported by qemu-kvm */ + QEMU_CAPS_MEM_PATH, /* mmap'ped guest backing supported */ + QEMU_CAPS_DRIVE_SERIAL, /* -driver serial= available */ + QEMU_CAPS_XEN_DOMID, /* -xen-domid (new style xen integration) */ + QEMU_CAPS_MIGRATE_QEMU_UNIX, /* Does qemu support unix domain sockets for migration? */ + QEMU_CAPS_CHARDEV, /* Is the new -chardev arg available */ + QEMU_CAPS_ENABLE_KVM, /* Is the -enable-kvm flag available to "enable KVM full virtualization support" */ + QEMU_CAPS_MONITOR_JSON, /* JSON mode for monitor */ + QEMU_CAPS_BALLOON, /* -balloon available */ + QEMU_CAPS_DEVICE, /* Is the new -device arg available */ + QEMU_CAPS_SDL, /* Is the new -sdl arg available */ + QEMU_CAPS_SMP_TOPOLOGY, /* Is sockets=s,cores=c,threads=t available for -smp? */ + QEMU_CAPS_NETDEV, /* The -netdev flag & netdev_add/remove monitor commands */ + QEMU_CAPS_RTC, /* The -rtc flag for clock options */ + QEMU_CAPS_VNET_HOST, /* vnet-host support is available in qemu */ + QEMU_CAPS_RTC_TD_HACK, /* -rtc-td-hack available */ + QEMU_CAPS_NO_HPET, /* -no-hpet flag is supported */ + QEMU_CAPS_NO_KVM_PIT, /* -no-kvm-pit-reinjection supported */ + QEMU_CAPS_TDF, /* -tdf flag (user-mode pit catchup) */ + QEMU_CAPS_PCI_CONFIGFD, /* pci-assign.configfd */ + QEMU_CAPS_NODEFCONFIG, /* -nodefconfig */ + QEMU_CAPS_BOOT_MENU, /* -boot menu=on support */ + QEMU_CAPS_ENABLE_KQEMU, /* -enable-kqemu flag */ + QEMU_CAPS_FSDEV, /* -fstype filesystem passthrough */ + QEMU_CAPS_NESTING, /* -enable-nesting (SVM/VMX) */ + QEMU_CAPS_NAME_PROCESS, /* Is -name process= available */ + QEMU_CAPS_DRIVE_READONLY, /* -drive readonly=on|off */ + QEMU_CAPS_SMBIOS_TYPE, /* Is -smbios type= available */ + QEMU_CAPS_VGA_QXL, /* The 'qxl' arg for '-vga' */ + QEMU_CAPS_SPICE, /* Is -spice avail */ + QEMU_CAPS_VGA_NONE, /* The 'none' arg for '-vga' */ + QEMU_CAPS_MIGRATE_QEMU_FD, /* -incoming fd:n */ + QEMU_CAPS_BOOTINDEX, /* -device bootindex property */ + QEMU_CAPS_HDA_DUPLEX, /* -device hda-duplex */ + QEMU_CAPS_DRIVE_AIO, /* -drive aio= supported */ + QEMU_CAPS_PCI_MULTIBUS, /* bus=pci.0 vs bus=pci */ + QEMU_CAPS_PCI_BOOTINDEX, /* pci-assign.bootindex */ + QEMU_CAPS_CCID_EMULATED, /* -device ccid-card-emulated */ + QEMU_CAPS_CCID_PASSTHRU, /* -device ccid-card-passthru */ + QEMU_CAPS_CHARDEV_SPICEVMC, /* newer -chardev spicevmc */ + QEMU_CAPS_DEVICE_SPICEVMC, /* older -device spicevmc*/ + + QEMU_CAPS_LAST, /* this must always be the last item */ }; -void qemuCapsSet(unsigned long long *caps, - enum qemuCapsFlags flag); +virBitmapPtr qemuCapsNew(void); + +# define qemuCapsFree(caps) virBitmapFree(caps) + +void qemuCapsSet(virBitmapPtr caps, + enum qemuCapsFlags flag) ATTRIBUTE_NONNULL(1); -void qemuCapsClear(unsigned long long *caps, - enum qemuCapsFlags flag); +void qemuCapsClear(virBitmapPtr caps, + enum qemuCapsFlags flag) ATTRIBUTE_NONNULL(1); -bool qemuCapsGet(unsigned long long caps, +bool qemuCapsGet(virBitmapPtr caps, enum qemuCapsFlags flag); virCapsPtr qemuCapsInit(virCapsPtr old_caps); @@ -110,7 +117,7 @@ int qemuCapsProbeMachineTypes(const char *binary, int *nmachines); int qemuCapsProbeCPUModels(const char *qemu, - unsigned long long qemuCaps, + virBitmapPtr qemuCaps, const char *arch, unsigned int *count, const char ***cpus); @@ -119,16 +126,16 @@ int qemuCapsExtractVersion(virCapsPtr caps, unsigned int *version); int qemuCapsExtractVersionInfo(const char *qemu, unsigned int *version, - unsigned long long *qemuCaps); + virBitmapPtr *qemuCaps); int qemuCapsParseHelpStr(const char *qemu, const char *str, - unsigned long long *qemuCaps, + virBitmapPtr qemuCaps, unsigned int *version, unsigned int *is_kvm, unsigned int *kvm_version); int qemuCapsParseDeviceStr(const char *str, - unsigned long long *qemuCaps); + virBitmapPtr qemuCaps); #endif /* __QEMU_CAPABILITIES_H__*/ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ab92ce8..3af39ba 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -109,7 +109,7 @@ int qemuPhysIfaceConnect(virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, - unsigned long long qemuCaps, + virBitmapPtr qemuCaps, const unsigned char *vmuuid, enum virVMOperationType vmop) { @@ -170,7 +170,7 @@ int qemuNetworkIfaceConnect(virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { char *brname = NULL; int err; @@ -304,7 +304,7 @@ cleanup: static int qemuOpenVhostNet(virDomainNetDefPtr net, - unsigned long long qemuCaps, + virBitmapPtr qemuCaps, int *vhostfd) { @@ -402,7 +402,7 @@ static int qemuAssignDeviceDiskAliasLegacy(virDomainDiskDefPtr disk) char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { char *ret; @@ -500,7 +500,7 @@ no_memory: int -qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, unsigned long long qemuCaps) +qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, virBitmapPtr qemuCaps) { if (qemuCapsGet(qemuCaps, QEMU_CAPS_DRIVE)) { if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) @@ -583,7 +583,7 @@ qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller) static int -qemuAssignDeviceAliases(virDomainDefPtr def, unsigned long long qemuCaps) +qemuAssignDeviceAliases(virDomainDefPtr def, virBitmapPtr qemuCaps) { int i; @@ -1094,7 +1094,7 @@ error: static int qemuBuildDeviceAddressStr(virBufferPtr buf, virDomainDeviceInfoPtr info, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { if (info->addr.pci.domain != 0) { @@ -1148,7 +1148,7 @@ qemuSafeSerialParamValue(const char *value) char * qemuBuildDriveStr(virDomainDiskDefPtr disk, int bootable, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer opt = VIR_BUFFER_INITIALIZER; const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus); @@ -1364,7 +1364,7 @@ error: char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer opt = VIR_BUFFER_INITIALIZER; const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus); @@ -1421,7 +1421,7 @@ error: char *qemuBuildFSStr(virDomainFSDefPtr fs, - unsigned long long qemuCaps ATTRIBUTE_UNUSED) + virBitmapPtr qemuCaps ATTRIBUTE_UNUSED) { virBuffer opt = VIR_BUFFER_INITIALIZER; @@ -1457,7 +1457,7 @@ error: char * qemuBuildFSDevStr(virDomainFSDefPtr fs, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer opt = VIR_BUFFER_INITIALIZER; @@ -1488,7 +1488,7 @@ error: char * qemuBuildControllerDevStr(virDomainControllerDefPtr def, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -1573,7 +1573,7 @@ qemuBuildNicStr(virDomainNetDefPtr net, char * qemuBuildNicDevStr(virDomainNetDefPtr net, int vlan, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; const char *nic; @@ -1718,7 +1718,7 @@ qemuBuildHostNetStr(virDomainNetDefPtr net, char * qemuBuildWatchdogDevStr(virDomainWatchdogDefPtr dev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -1749,7 +1749,7 @@ error: char * qemuBuildMemballoonDevStr(virDomainMemballoonDefPtr dev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -1796,7 +1796,7 @@ error: char * qemuBuildSoundDevStr(virDomainSoundDefPtr sound, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; const char *model = virDomainSoundModelTypeToString(sound->model); @@ -1858,7 +1858,7 @@ error: static char * qemuBuildVideoDevStr(virDomainVideoDefPtr video, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; const char *model = qemuVideoTypeToString(video->type); @@ -1914,7 +1914,7 @@ qemuOpenPCIConfig(virDomainHostdevDefPtr dev) char * qemuBuildPCIHostdevDevStr(virDomainHostdevDefPtr dev, const char *configfd, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -2007,7 +2007,7 @@ qemuBuildUSBHostdevUsbDevStr(virDomainHostdevDefPtr dev) * host side of the character device */ static char * qemuBuildChrChardevStr(virDomainChrSourceDefPtr dev, const char *alias, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; bool telnet; @@ -2185,7 +2185,7 @@ error: static char * qemuBuildVirtioSerialPortDevStr(virDomainChrDefPtr dev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE) @@ -2423,7 +2423,7 @@ static int qemuBuildCpuArgStr(const struct qemud_driver *driver, const virDomainDefPtr def, const char *emulator, - unsigned long long qemuCaps, + virBitmapPtr qemuCaps, const struct utsname *ut, char **opt, bool *hasHwVirt) @@ -2546,7 +2546,7 @@ no_memory: static char * qemuBuildSmpArgStr(const virDomainDefPtr def, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -2599,7 +2599,7 @@ qemuBuildCommandLine(virConnectPtr conn, virDomainDefPtr def, virDomainChrSourceDefPtr monitor_chr, bool monitor_json, - unsigned long long qemuCaps, + virBitmapPtr qemuCaps, const char *migrateFrom, int migrateFd, virDomainSnapshotObjPtr current_snapshot, @@ -2637,7 +2637,7 @@ qemuBuildCommandLine(virConnectPtr conn, */ if (qemuCapsGet(qemuCaps, QEMU_CAPS_KVM) && (def->virtType == VIR_DOMAIN_VIRT_QEMU)) - qemuCapsClear(&qemuCaps, QEMU_CAPS_DRIVE_BOOT); + qemuCapsClear(qemuCaps, QEMU_CAPS_DRIVE_BOOT); switch (def->virtType) { case VIR_DOMAIN_VIRT_QEMU: @@ -2687,7 +2687,7 @@ qemuBuildCommandLine(virConnectPtr conn, /* Currently only x86_64 and i686 support PCI-multibus. */ if (STREQLEN(def->os.arch, "x86_64", 6) || STREQLEN(def->os.arch, "i686", 4)) { - qemuCapsSet(&qemuCaps, QEMU_CAPS_PCI_MULTIBUS); + qemuCapsSet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS); } cmd = virCommandNewArgList(emulator, "-S", NULL); @@ -3185,13 +3185,13 @@ qemuBuildCommandLine(virConnectPtr conn, if (disk->bus != VIR_DOMAIN_DISK_BUS_XEN) { withDeviceArg = 1; } else { - qemuCapsClear(&qemuCaps, QEMU_CAPS_DEVICE); + qemuCapsClear(qemuCaps, QEMU_CAPS_DEVICE); deviceFlagMasked = true; } } optstr = qemuBuildDriveStr(disk, bootable, qemuCaps); if (deviceFlagMasked) - qemuCapsSet(&qemuCaps, QEMU_CAPS_DEVICE); + qemuCapsSet(qemuCaps, QEMU_CAPS_DEVICE); if (!optstr) goto error; virCommandAddArg(cmd, optstr); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 65af8d8..fd8b323 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -42,7 +42,7 @@ virCommandPtr qemuBuildCommandLine(virConnectPtr conn, virDomainDefPtr def, virDomainChrSourceDefPtr monitor_chr, bool monitor_json, - unsigned long long qemuCaps, + virBitmapPtr qemuCaps, const char *migrateFrom, int migrateFd, virDomainSnapshotObjPtr current_snapshot, @@ -64,44 +64,44 @@ char * qemuBuildNicStr(virDomainNetDefPtr net, /* Current, best practice */ char * qemuBuildNicDevStr(virDomainNetDefPtr net, int vlan, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); /* Both legacy & current support */ char *qemuBuildDriveStr(virDomainDiskDefPtr disk, int bootable, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); char *qemuBuildFSStr(virDomainFSDefPtr fs, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); /* Current, best practice */ char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); char * qemuBuildFSDevStr(virDomainFSDefPtr fs, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); /* Current, best practice */ char * qemuBuildControllerDevStr(virDomainControllerDefPtr def, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); char * qemuBuildWatchdogDevStr(virDomainWatchdogDefPtr dev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); char * qemuBuildMemballoonDevStr(virDomainMemballoonDefPtr dev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); char * qemuBuildUSBInputDevStr(virDomainInputDefPtr dev); char * qemuBuildSoundDevStr(virDomainSoundDefPtr sound, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); /* Legacy, pre device support */ char * qemuBuildPCIHostdevPCIDevStr(virDomainHostdevDefPtr dev); /* Current, best practice */ char * qemuBuildPCIHostdevDevStr(virDomainHostdevDefPtr dev, const char *configfd, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuOpenPCIConfig(virDomainHostdevDefPtr dev); @@ -115,13 +115,13 @@ char * qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev); int qemuNetworkIfaceConnect(virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) ATTRIBUTE_NONNULL(1); int qemuPhysIfaceConnect(virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, - unsigned long long qemuCaps, + virBitmapPtr qemuCaps, const unsigned char *vmuuid, enum virVMOperationType vmop); @@ -151,7 +151,7 @@ int qemuAssignDevicePCISlots(virDomainDefPtr def, qemuDomainPCIAddressSetPtr ad int qemuDomainNetVLAN(virDomainNetDefPtr def); int qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx); -int qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, unsigned long long qemuCaps); +int qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, virBitmapPtr qemuCaps); int qemuAssignDeviceHostdevAlias(virDomainDefPtr def, virDomainHostdevDefPtr net, int idx); int qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f76d452..481062e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -919,7 +919,7 @@ qemuReconnectDomain(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaq struct virReconnectDomainData *data = opaque; struct qemud_driver *driver = data->driver; qemuDomainObjPrivatePtr priv; - unsigned long long qemuCaps; + virBitmapPtr qemuCaps = NULL; virConnectPtr conn = data->conn; virDomainObjLock(obj); @@ -965,9 +965,12 @@ qemuReconnectDomain(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaq if (virDomainObjUnref(obj) > 0) virDomainObjUnlock(obj); + + qemuCapsFree(qemuCaps); return; error: + qemuCapsFree(qemuCaps); if (!virDomainObjIsActive(obj)) { if (virDomainObjUnref(obj) > 0) virDomainObjUnlock(obj); @@ -2000,7 +2003,7 @@ static int qemuInitPasswords(virConnectPtr conn, struct qemud_driver *driver, virDomainObjPtr vm, - unsigned long long qemuCaps) { + virBitmapPtr qemuCaps) { int ret = 0; qemuDomainObjPrivatePtr priv = vm->privateData; @@ -2513,7 +2516,7 @@ static int qemuAssignPCIAddresses(virDomainDefPtr def) { int ret = -1; - unsigned long long qemuCaps = 0; + virBitmapPtr qemuCaps = NULL; qemuDomainPCIAddressSetPtr addrs = NULL; if (qemuCapsExtractVersionInfo(def->emulator, @@ -2532,6 +2535,7 @@ qemuAssignPCIAddresses(virDomainDefPtr def) ret = 0; cleanup: + qemuCapsFree(qemuCaps); qemuDomainPCIAddressSetFree(addrs); return ret; @@ -2622,7 +2626,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, const char *stdin_path, enum virVMOperationType vmop) { int ret; - unsigned long long qemuCaps; + virBitmapPtr qemuCaps = NULL; off_t pos = -1; char ebuf[1024]; char *pidfile = NULL; @@ -2959,6 +2963,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) goto cleanup; + qemuCapsFree(qemuCaps); virCommandFree(cmd); VIR_FORCE_CLOSE(logfile); @@ -2968,6 +2973,7 @@ cleanup: /* We jump here if we failed to start the VM for any reason, or * if we failed to initialize the now running VM. kill it off and * pretend we never started it */ + qemuCapsFree(qemuCaps); virCommandFree(cmd); VIR_FORCE_CLOSE(logfile); qemudShutdownVMDaemon(driver, vm, 0); @@ -6097,7 +6103,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, struct qemud_driver *driver = conn->privateData; virDomainDefPtr def = NULL; virDomainChrSourceDef monConfig; - unsigned long long qemuCaps; + virBitmapPtr qemuCaps = NULL; virCommandPtr cmd = NULL; char *ret = NULL; int i; @@ -6170,6 +6176,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, cleanup: qemuDriverUnlock(driver); + qemuCapsFree(qemuCaps); virCommandFree(cmd); virDomainDefFree(def); return ret; @@ -6506,7 +6513,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom, struct qemud_driver *driver = dom->conn->privateData; virDomainObjPtr vm; virDomainDeviceDefPtr dev = NULL; - unsigned long long qemuCaps; + virBitmapPtr qemuCaps = NULL; virCgroupPtr cgroup = NULL; int ret = -1; @@ -6637,6 +6644,7 @@ cleanup: if (cgroup) virCgroupFree(&cgroup); + qemuCapsFree(qemuCaps); virDomainDeviceDefFree(dev); if (vm) virDomainObjUnlock(vm); @@ -6664,7 +6672,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom, struct qemud_driver *driver = dom->conn->privateData; virDomainObjPtr vm; virDomainDeviceDefPtr dev = NULL; - unsigned long long qemuCaps; + virBitmapPtr qemuCaps = NULL; virCgroupPtr cgroup = NULL; int ret = -1; bool force = (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) != 0; @@ -6770,6 +6778,7 @@ cleanup: if (cgroup) virCgroupFree(&cgroup); + qemuCapsFree(qemuCaps); virDomainDeviceDefFree(dev); if (vm) virDomainObjUnlock(vm); @@ -6782,7 +6791,7 @@ static int qemudDomainDetachDevice(virDomainPtr dom, const char *xml) { struct qemud_driver *driver = dom->conn->privateData; virDomainObjPtr vm; - unsigned long long qemuCaps; + virBitmapPtr qemuCaps = NULL; virDomainDeviceDefPtr dev = NULL; int ret = -1; @@ -6855,6 +6864,7 @@ endjob: vm = NULL; cleanup: + qemuCapsFree(qemuCaps); virDomainDeviceDefFree(dev); if (vm) virDomainObjUnlock(vm); @@ -8004,7 +8014,7 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, int ret = -1; int internalret; char *unixfile = NULL; - unsigned long long qemuCaps; + virBitmapPtr qemuCaps = NULL; qemuDomainObjPrivatePtr priv = NULL; struct timeval now; @@ -8156,6 +8166,7 @@ endjob: } cleanup: + qemuCapsFree(qemuCaps); virDomainDefFree(def); if (unixfile) unlink(unixfile); @@ -8528,7 +8539,7 @@ static int doTunnelMigrate(virDomainPtr dom, virStreamPtr st = NULL; char *unixfile = NULL; int internalret; - unsigned long long qemuCaps; + virBitmapPtr qemuCaps = NULL; int status; unsigned long long transferred, remaining, total; unsigned int background_flags = QEMU_MONITOR_MIGRATE_BACKGROUND; @@ -8713,6 +8724,7 @@ finish: cleanup: VIR_FORCE_CLOSE(client_sock); VIR_FORCE_CLOSE(qemu_sock); + qemuCapsFree(qemuCaps); if (ddomain) virUnrefDomain(ddomain); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index a6e3f2b..d148553 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -44,7 +44,7 @@ int qemuDomainChangeEjectableMedia(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, - unsigned long long qemuCaps, + virBitmapPtr qemuCaps, bool force) { virDomainDiskDefPtr origdisk = NULL; @@ -140,7 +140,7 @@ error: int qemuDomainAttachPciDiskDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { int i, ret; const char* type = virDomainDiskBusTypeToString(disk->bus); @@ -235,7 +235,7 @@ error: int qemuDomainAttachPciControllerDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainControllerDefPtr controller, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { int i; int ret = -1; @@ -300,7 +300,7 @@ static virDomainControllerDefPtr qemuDomainFindOrCreateSCSIDiskController(struct qemud_driver *driver, virDomainObjPtr vm, int controller, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { int i; virDomainControllerDefPtr cont; @@ -346,7 +346,7 @@ qemuDomainFindOrCreateSCSIDiskController(struct qemud_driver *driver, int qemuDomainAttachSCSIDisk(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { int i; qemuDomainObjPrivatePtr priv = vm->privateData; @@ -462,7 +462,7 @@ error: int qemuDomainAttachUsbMassstorageDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { qemuDomainObjPrivatePtr priv = vm->privateData; int i, ret; @@ -547,7 +547,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, struct qemud_driver *driver, virDomainObjPtr vm, virDomainNetDefPtr net, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { qemuDomainObjPrivatePtr priv = vm->privateData; char *tapfd_name = NULL; @@ -777,7 +777,7 @@ no_memory: int qemuDomainAttachHostPciDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { qemuDomainObjPrivatePtr priv = vm->privateData; int ret; @@ -872,7 +872,7 @@ error: int qemuDomainAttachHostUsbDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { int ret; qemuDomainObjPrivatePtr priv = vm->privateData; @@ -935,7 +935,7 @@ error: int qemuDomainAttachHostDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -1130,7 +1130,7 @@ static inline int qemuFindDisk(virDomainDefPtr def, const char *dst) int qemuDomainDetachPciDiskDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { int i, ret = -1; virDomainDiskDefPtr detach = NULL; @@ -1221,7 +1221,7 @@ cleanup: int qemuDomainDetachSCSIDiskDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { int i, ret = -1; virDomainDiskDefPtr detach = NULL; @@ -1300,7 +1300,7 @@ cleanup: int qemuDomainDetachPciControllerDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { int i, ret = -1; virDomainControllerDefPtr detach = NULL; @@ -1378,7 +1378,7 @@ cleanup: int qemuDomainDetachNetDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { int i, ret = -1; virDomainNetDefPtr detach = NULL; @@ -1505,7 +1505,7 @@ cleanup: int qemuDomainDetachHostPciDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virDomainHostdevDefPtr detach = NULL; qemuDomainObjPrivatePtr priv = vm->privateData; @@ -1605,7 +1605,7 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver *driver, int qemuDomainDetachHostUsbDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virDomainHostdevDefPtr detach = NULL; qemuDomainObjPrivatePtr priv = vm->privateData; @@ -1687,7 +1687,7 @@ int qemuDomainDetachHostUsbDevice(struct qemud_driver *driver, int qemuDomainDetachHostDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps) + virBitmapPtr qemuCaps) { virDomainHostdevDefPtr hostdev = dev->data.hostdev; int ret; diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index a5eadd3..984c3b8 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -32,41 +32,41 @@ int qemuDomainChangeEjectableMedia(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, - unsigned long long qemuCaps, + virBitmapPtr qemuCaps, bool force); int qemuDomainAttachPciDiskDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainAttachPciControllerDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainControllerDefPtr controller, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainAttachSCSIDisk(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainAttachUsbMassstorageDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainAttachNetDevice(virConnectPtr conn, struct qemud_driver *driver, virDomainObjPtr vm, virDomainNetDefPtr net, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainAttachHostPciDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainAttachHostUsbDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainAttachHostDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainHostdevDefPtr hostdev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainChangeGraphics(struct qemud_driver *driver, virDomainObjPtr vm, virDomainGraphicsDefPtr dev); @@ -78,31 +78,31 @@ int qemuDomainChangeGraphicsPasswords(struct qemud_driver *driver, int qemuDomainDetachPciDiskDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainDetachSCSIDiskDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainDetachPciControllerDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainDetachNetDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainDetachHostPciDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainDetachHostUsbDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); int qemuDomainDetachHostDevice(struct qemud_driver *driver, virDomainObjPtr vm, virDomainDeviceDefPtr dev, - unsigned long long qemuCaps); + virBitmapPtr qemuCaps); #endif /* __QEMU_HOTPLUG_H__ */ -- 1.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list