From c8c3764b557f97976c6c557b03810364c0569cbf Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Jan 17 2017 15:27:37 +0000 Subject: import libvirt-2.0.0-10.el7_3.4 --- diff --git a/SOURCES/libvirt-qemu-snapshot-Don-t-attempt-to-resume-cpus-if-they-were-not-paused.patch b/SOURCES/libvirt-qemu-snapshot-Don-t-attempt-to-resume-cpus-if-they-were-not-paused.patch new file mode 100644 index 0000000..f6d5446 --- /dev/null +++ b/SOURCES/libvirt-qemu-snapshot-Don-t-attempt-to-resume-cpus-if-they-were-not-paused.patch @@ -0,0 +1,52 @@ +From d5c66c2071bea9632a4a612ce355fca79d7d372c Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Tue, 20 Dec 2016 18:18:16 +0100 +Subject: [PATCH] qemu: snapshot: Don't attempt to resume cpus if they were not + paused + +External disk-only snapshots with recent enough qemu don't require +libvirt to pause the VM. The logic determining when to resume cpus was +slightly flawed and attempted to resume them even if they were not +paused by the snapshot code. This normally was not a problem, but with +locking enabled the code would attempt to acquire the lock twice. + +The fallout of this bug would be a error from the API, but the actual +snapshot being created. The bug was introduced with when adding support +for external snapshots with memory (checkpoints) in commit f569b87. + +Resolves problems described by: +https://bugzilla.redhat.com/show_bug.cgi?id=1403691 (7.4) + +(cherry picked from commit 4b951d1e38259ff5d03e9eedb65095eead8099e1) + +https://bugzilla.redhat.com/show_bug.cgi?id=1406765 +--- + src/qemu/qemu_driver.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index 1e02a7f33..2e442a987 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -14323,8 +14323,6 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, + if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PMSUSPENDED) { + pmsuspended = true; + } else if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) { +- resume = true; +- + /* For external checkpoints (those with memory), the guest + * must pause (either by libvirt up front, or by qemu after + * _LIVE converges). For disk-only snapshots with multiple +@@ -14347,6 +14345,8 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, + _("guest unexpectedly quit")); + goto cleanup; + } ++ ++ resume = true; + } + } + +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemu-snapshot-Resume-VM-after-live-snapshot.patch b/SOURCES/libvirt-qemu-snapshot-Resume-VM-after-live-snapshot.patch new file mode 100644 index 0000000..c66caf6 --- /dev/null +++ b/SOURCES/libvirt-qemu-snapshot-Resume-VM-after-live-snapshot.patch @@ -0,0 +1,35 @@ +From b17a6448e31684225e8c28aeba661a71a22dc917 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Thu, 5 Jan 2017 09:48:13 +0100 +Subject: [PATCH] qemu: snapshot: Resume VM after live snapshot + +Commit 4b951d1e38259ff5d03e9eedb65095eead8099e1 missed the fact that the +VM needs to be resumed after a live external checkpoint (memory +snapshot) where the cpus would be paused by the migration rather than +libvirt. + +(cherry picked from commit 2e86c0816fc8ab573745f1a9a650be09bd66e300) + +https://bugzilla.redhat.com/show_bug.cgi?id=1406765 +--- + src/qemu/qemu_driver.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index 2e442a987..37b09998d 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -14334,6 +14334,9 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn, + * atomic flag now says whether we need to pause, and a + * capability bit says whether to use transaction. + */ ++ if (memory) ++ resume = true; ++ + if ((memory && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_LIVE)) || + (!memory && atomic && !transaction)) { + if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_SNAPSHOT, +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuBuildChrChardevStr-Introduce-nowait-argument.patch b/SOURCES/libvirt-qemuBuildChrChardevStr-Introduce-nowait-argument.patch new file mode 100644 index 0000000..e1437ca --- /dev/null +++ b/SOURCES/libvirt-qemuBuildChrChardevStr-Introduce-nowait-argument.patch @@ -0,0 +1,165 @@ +From cc05f5db0c1051dc3e1ded20410fce4560b19ea3 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:09 +0100 +Subject: [PATCH] qemuBuildChrChardevStr: Introduce @nowait argument + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +This alone makes not much sense. But the aim is to reuse this +function in qemuBuildVhostuserCommandLine() where 'nowait' is not +supported for vhost-user devices. + +Conflict: Because e3d3c04a is not backported. + +Signed-off-by: Michal Privoznik +(cherry picked from commit 336d4a71feb1cd68df13e1812e86971c61553522) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_command.c | 36 ++++++++++++++++++++---------------- + 1 file changed, 20 insertions(+), 16 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index d88ee5b6b..d28a367cc 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -4891,7 +4891,8 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, + const virDomainDef *def, + const virDomainChrSourceDef *dev, + const char *alias, +- virQEMUCapsPtr qemuCaps) ++ virQEMUCapsPtr qemuCaps, ++ bool nowait) + { + virBuffer buf = VIR_BUFFER_INITIALIZER; + bool telnet; +@@ -4964,19 +4965,22 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, + case VIR_DOMAIN_CHR_TYPE_TCP: + telnet = dev->data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET; + virBufferAsprintf(&buf, +- "socket,id=char%s,host=%s,port=%s%s%s", ++ "socket,id=char%s,host=%s,port=%s%s", + alias, + dev->data.tcp.host, + dev->data.tcp.service, +- telnet ? ",telnet" : "", +- dev->data.tcp.listen ? ",server,nowait" : ""); ++ telnet ? ",telnet" : ""); ++ ++ if (dev->data.tcp.listen) ++ virBufferAdd(&buf, nowait ? ",server,nowait" : ",server", -1); ++ + break; + + case VIR_DOMAIN_CHR_TYPE_UNIX: + virBufferAsprintf(&buf, "socket,id=char%s,path=", alias); + virQEMUBuildBufferEscapeComma(&buf, dev->data.nix.path); + if (dev->data.nix.listen) +- virBufferAddLit(&buf, ",server,nowait"); ++ virBufferAdd(&buf, nowait ? ",server,nowait" : ",server", -1); + break; + + case VIR_DOMAIN_CHR_TYPE_SPICEVMC: +@@ -5300,7 +5304,7 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManager, + + if (!(chrdev = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + monitor_chr, "monitor", +- qemuCaps))) ++ qemuCaps, true))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, chrdev); +@@ -5460,7 +5464,7 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager, + case VIR_DOMAIN_RNG_BACKEND_EGD: + if (!(*chr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + rng->source.chardev, +- rng->info.alias, qemuCaps))) ++ rng->info.alias, qemuCaps, true))) + return -1; + } + +@@ -8461,7 +8465,7 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + &smartcard->data.passthru, + smartcard->info.alias, +- qemuCaps))) { ++ qemuCaps, true))) { + virBufferFreeAndReset(&opt); + return -1; + } +@@ -8594,7 +8598,7 @@ qemuBuildShmemBackendChrStr(virLogManagerPtr logManager, + + devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + &shmem->server.chr, +- shmem->info.alias, qemuCaps); ++ shmem->info.alias, qemuCaps, true); + + return devstr; + } +@@ -8764,7 +8768,7 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + &serial->source, + serial->info.alias, +- qemuCaps))) ++ qemuCaps, true))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -8803,7 +8807,7 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + ¶llel->source, + parallel->info.alias, +- qemuCaps))) ++ qemuCaps, true))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -8849,7 +8853,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + &channel->source, + channel->info.alias, +- qemuCaps))) ++ qemuCaps, true))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -8872,7 +8876,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + &channel->source, + channel->info.alias, +- qemuCaps))) ++ qemuCaps, true))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -8915,7 +8919,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + &console->source, + console->info.alias, +- qemuCaps))) ++ qemuCaps, true))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -8929,7 +8933,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + &console->source, + console->info.alias, +- qemuCaps))) ++ qemuCaps, true))) + return -1; + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, devstr); +@@ -9058,7 +9062,7 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, + &redirdev->source.chr, + redirdev->info.alias, +- qemuCaps))) { ++ qemuCaps, true))) { + return -1; + } + +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuBuildHostNetStr-Explicitly-enumerate-net-types.patch b/SOURCES/libvirt-qemuBuildHostNetStr-Explicitly-enumerate-net-types.patch new file mode 100644 index 0000000..6e28722 --- /dev/null +++ b/SOURCES/libvirt-qemuBuildHostNetStr-Explicitly-enumerate-net-types.patch @@ -0,0 +1,52 @@ +From 67133474cb7914e4666392eb02f8c24cfa083586 Mon Sep 17 00:00:00 2001 +Message-Id: <67133474cb7914e4666392eb02f8c24cfa083586@dist-git> +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:08 +0100 +Subject: [PATCH] qemuBuildHostNetStr: Explicitly enumerate net types + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +We tend to prevent using 'default' in switches. And it is for a +good reason - control may end up in paths we wouldn't want for +new values. In this specific case, if qemuBuildHostNetStr is +called over VIR_DOMAIN_NET_TYPE_VHOSTUSER it would produce +meaningless output. Fortunately, there no such call yet. + +Signed-off-by: Michal Privoznik +(cherry picked from commit 1dcbef8a0f4bdfb25bf6b8cac08afd1a589c1ccd) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_command.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 8bebe437a..d88ee5b6b 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -3676,9 +3676,21 @@ qemuBuildHostNetStr(virDomainNetDefPtr net, + break; + + case VIR_DOMAIN_NET_TYPE_USER: +- default: ++ case VIR_DOMAIN_NET_TYPE_INTERNAL: + virBufferAddLit(&buf, "user"); + break; ++ ++ case VIR_DOMAIN_NET_TYPE_HOSTDEV: ++ /* Should have been handled earlier via PCI/USB hotplug code. */ ++ virObjectUnref(cfg); ++ return NULL; ++ ++ case VIR_DOMAIN_NET_TYPE_VHOSTUSER: ++ /* Unsupported yet. */ ++ break; ++ ++ case VIR_DOMAIN_NET_TYPE_LAST: ++ break; + } + + if (vlan >= 0) { +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuBuildHostNetStr-Support-VIR_DOMAIN_NET_TYPE_VHOSTUSER.patch b/SOURCES/libvirt-qemuBuildHostNetStr-Support-VIR_DOMAIN_NET_TYPE_VHOSTUSER.patch new file mode 100644 index 0000000..bb78c76 --- /dev/null +++ b/SOURCES/libvirt-qemuBuildHostNetStr-Support-VIR_DOMAIN_NET_TYPE_VHOSTUSER.patch @@ -0,0 +1,147 @@ +From e7f4b5ba8ea0fcba470de26fac9fca059253f8c5 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:12 +0100 +Subject: [PATCH] qemuBuildHostNetStr: Support VIR_DOMAIN_NET_TYPE_VHOSTUSER + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 +RHEL-7.4: https://bugzilla.redhat.com/show_bug.cgi?id=1366505 + +So far, this function lacked support for +VIR_DOMAIN_NET_TYPE_VHOSTUSER leaving callers to hack around the +problem by constructing the command line on their own. This is +not ideal as it blocks hot plug support. + +Signed-off-by: Michal Privoznik +(cherry picked from commit e1844d85cbdcb3ed8199ae8ae5274ffcc4968aa5) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_command.c | 38 +++++++++++++--------- + .../qemuxml2argv-net-vhostuser-multiq.args | 6 ++-- + .../qemuxml2argv-net-vhostuser.args | 4 +-- + 3 files changed, 28 insertions(+), 20 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index aa289ad64..ade9e2524 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -3686,7 +3686,13 @@ qemuBuildHostNetStr(virDomainNetDefPtr net, + return NULL; + + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: +- /* Unsupported yet. */ ++ virBufferAsprintf(&buf, "vhost-user%cchardev=char%s", ++ type_sep, ++ net->info.alias); ++ type_sep = ','; ++ if (net->driver.virtio.queues > 1) ++ virBufferAsprintf(&buf, ",queues=%u", ++ net->driver.virtio.queues); + break; + + case VIR_DOMAIN_NET_TYPE_LAST: +@@ -7918,7 +7924,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, + { + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + char *chardev = NULL; +- virBuffer netdev_buf = VIR_BUFFER_INITIALIZER; ++ char *netdev = NULL; + unsigned int queues = net->driver.virtio.queues; + char *nic = NULL; + +@@ -7955,25 +7961,27 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, + goto error; + } + +- virBufferAsprintf(&netdev_buf, "vhost-user,id=host%s,chardev=char%s", +- net->info.alias, net->info.alias); +- +- if (queues > 1) { +- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", +- _("multi-queue is not supported for vhost-user " +- "with this QEMU binary")); +- goto error; +- } +- virBufferAsprintf(&netdev_buf, ",queues=%u", queues); ++ if (queues > 1 && ++ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE)) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", ++ _("multi-queue is not supported for vhost-user " ++ "with this QEMU binary")); ++ goto error; + } + ++ if (!(netdev = qemuBuildHostNetStr(net, driver, ++ ',', -1, ++ NULL, 0, NULL, 0))) ++ goto error; ++ ++ + virCommandAddArg(cmd, "-chardev"); + virCommandAddArg(cmd, chardev); + VIR_FREE(chardev); + + virCommandAddArg(cmd, "-netdev"); +- virCommandAddArgBuffer(cmd, &netdev_buf); ++ virCommandAddArg(cmd, netdev); ++ VIR_FREE(netdev); + + if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex, + queues, qemuCaps))) { +@@ -7990,8 +7998,8 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, + + error: + virObjectUnref(cfg); ++ VIR_FREE(netdev); + VIR_FREE(chardev); +- virBufferFreeAndReset(&netdev_buf); + VIR_FREE(nic); + + return -1; +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args +index 48930ef16..6664767a1 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args ++++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args +@@ -20,16 +20,16 @@ QEMU_AUDIO_DRV=none \ + -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ + -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ + -chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \ +--netdev vhost-user,id=hostnet0,chardev=charnet0 \ ++-netdev vhost-user,chardev=charnet0,id=hostnet0 \ + -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\ + addr=0x3 \ + -chardev socket,id=charnet1,path=/tmp/vhost1.sock \ +--netdev vhost-user,id=hostnet1,chardev=charnet1 \ ++-netdev vhost-user,chardev=charnet1,id=hostnet1 \ + -device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,\ + addr=0x4 \ + -netdev socket,listen=:2015,id=hostnet2 \ + -device rtl8139,netdev=hostnet2,id=net2,mac=52:54:00:95:db:c0,bus=pci.0,addr=0x5 \ + -chardev socket,id=charnet3,path=/tmp/vhost2.sock \ +--netdev vhost-user,id=hostnet3,chardev=charnet3,queues=4 \ ++-netdev vhost-user,chardev=charnet3,queues=4,id=hostnet3 \ + -device virtio-net-pci,mq=on,vectors=10,netdev=hostnet3,id=net3,\ + mac=52:54:00:ee:96:6d,bus=pci.0,addr=0x6 +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args +index f4dc9d573..2415645f7 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args ++++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args +@@ -20,11 +20,11 @@ QEMU_AUDIO_DRV=none \ + -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ + -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ + -chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \ +--netdev vhost-user,id=hostnet0,chardev=charnet0 \ ++-netdev vhost-user,chardev=charnet0,id=hostnet0 \ + -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\ + addr=0x3 \ + -chardev socket,id=charnet1,path=/tmp/vhost1.sock \ +--netdev vhost-user,id=hostnet1,chardev=charnet1 \ ++-netdev vhost-user,chardev=charnet1,id=hostnet1 \ + -device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,\ + addr=0x4 \ + -netdev socket,listen=:2015,id=hostnet2 \ +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuBuildInterfaceCommandLine-Move-from-if-else-forest-to-switch.patch b/SOURCES/libvirt-qemuBuildInterfaceCommandLine-Move-from-if-else-forest-to-switch.patch new file mode 100644 index 0000000..a16afac --- /dev/null +++ b/SOURCES/libvirt-qemuBuildInterfaceCommandLine-Move-from-if-else-forest-to-switch.patch @@ -0,0 +1,94 @@ +From 26de75ae434598a20fb68d4a7a4701f463f6328c Mon Sep 17 00:00:00 2001 +Message-Id: <26de75ae434598a20fb68d4a7a4701f463f6328c@dist-git> +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:05 +0100 +Subject: [PATCH] qemuBuildInterfaceCommandLine: Move from if-else forest to + switch + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +Signed-off-by: Michal Privoznik +(cherry picked from commit 0bce012d7f0bbf68c1b42a93d7d1c4e085e2695e) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_command.c | 34 +++++++++++++++++++++++++++------- + 1 file changed, 27 insertions(+), 7 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index a9b91213d..8bebe437a 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -8041,8 +8041,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + + cfg = virQEMUDriverGetConfig(driver); + +- if (actualType == VIR_DOMAIN_NET_TYPE_NETWORK || +- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) { ++ switch (actualType) { ++ case VIR_DOMAIN_NET_TYPE_NETWORK: ++ case VIR_DOMAIN_NET_TYPE_BRIDGE: + tapfdSize = net->driver.virtio.queues; + if (!tapfdSize) + tapfdSize = 1; +@@ -8056,7 +8057,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + if (qemuInterfaceBridgeConnect(def, driver, net, + tapfd, &tapfdSize) < 0) + goto cleanup; +- } else if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) { ++ break; ++ ++ case VIR_DOMAIN_NET_TYPE_DIRECT: + tapfdSize = net->driver.virtio.queues; + if (!tapfdSize) + tapfdSize = 1; +@@ -8070,7 +8073,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + if (qemuInterfaceDirectConnect(def, driver, net, + tapfd, tapfdSize, vmop) < 0) + goto cleanup; +- } else if (actualType == VIR_DOMAIN_NET_TYPE_ETHERNET) { ++ break; ++ ++ case VIR_DOMAIN_NET_TYPE_ETHERNET: + tapfdSize = net->driver.virtio.queues; + if (!tapfdSize) + tapfdSize = 1; +@@ -8082,17 +8087,32 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + memset(tapfd, -1, tapfdSize * sizeof(tapfd[0])); + + if (qemuInterfaceEthernetConnect(def, driver, net, +- tapfd, tapfdSize) < 0) ++ tapfd, tapfdSize) < 0) + goto cleanup; +- } else if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { ++ break; ++ ++ case VIR_DOMAIN_NET_TYPE_HOSTDEV: + /* NET_TYPE_HOSTDEV devices are really hostdev devices, so + * their commandlines are constructed with other hostdevs. + */ + ret = 0; + goto cleanup; +- } else if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) { ++ break; ++ ++ case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + ret = qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps, bootindex); + goto cleanup; ++ break; ++ ++ case VIR_DOMAIN_NET_TYPE_USER: ++ case VIR_DOMAIN_NET_TYPE_SERVER: ++ case VIR_DOMAIN_NET_TYPE_CLIENT: ++ case VIR_DOMAIN_NET_TYPE_MCAST: ++ case VIR_DOMAIN_NET_TYPE_INTERNAL: ++ case VIR_DOMAIN_NET_TYPE_UDP: ++ case VIR_DOMAIN_NET_TYPE_LAST: ++ /* nada */ ++ break; + } + + /* For types whose implementations use a netdev on the host, add +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuBuildInterfaceCommandLine-Move-hostdev-handling-a-bit-further.patch b/SOURCES/libvirt-qemuBuildInterfaceCommandLine-Move-hostdev-handling-a-bit-further.patch new file mode 100644 index 0000000..fe1b117 --- /dev/null +++ b/SOURCES/libvirt-qemuBuildInterfaceCommandLine-Move-hostdev-handling-a-bit-further.patch @@ -0,0 +1,119 @@ +From 62821d2db6a1d60bc00c22d4da021999772bd2e4 Mon Sep 17 00:00:00 2001 +Message-Id: <62821d2db6a1d60bc00c22d4da021999772bd2e4@dist-git> +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:03 +0100 +Subject: [PATCH] qemuBuildInterfaceCommandLine: Move hostdev handling a bit + further + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +The idea is to have function that does some checking of the +arguments at its beginning and then have one big switch for all +the interface types it supports. Each one of them generating the +corresponding part of the command line. + +Signed-off-by: Michal Privoznik +(cherry picked from commit ec7f612a56ed8d3a2e83101b5cffcea3058fd30a) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_command.c | 13 ++++---- + .../qemuxml2argv-net-hostdev-fail.xml | 39 ++++++++++++++++++++++ + tests/qemuxml2argvtest.c | 4 +++ + 3 files changed, 49 insertions(+), 7 deletions(-) + create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-fail.xml + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 8d002ffb2..1e7d9209a 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -8007,13 +8007,6 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) + return qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps, bootindex); + +- if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { +- /* NET_TYPE_HOSTDEV devices are really hostdev devices, so +- * their commandlines are constructed with other hostdevs. +- */ +- return 0; +- } +- + /* Currently nothing besides TAP devices supports multiqueue. */ + if (net->driver.virtio.queues > 0 && + !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || +@@ -8093,6 +8086,12 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + if (qemuInterfaceEthernetConnect(def, driver, net, + tapfd, tapfdSize) < 0) + goto cleanup; ++ } else if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { ++ /* NET_TYPE_HOSTDEV devices are really hostdev devices, so ++ * their commandlines are constructed with other hostdevs. ++ */ ++ ret = 0; ++ goto cleanup; + } + + /* For types whose implementations use a netdev on the host, add +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-fail.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-fail.xml +new file mode 100644 +index 000000000..7807d793f +--- /dev/null ++++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev-fail.xml +@@ -0,0 +1,39 @@ ++ ++ QEMUGuest1 ++ c7a5fdbd-edaf-9455-926a-d65c16db1809 ++ 219136 ++ 219136 ++ 1 ++ ++ hvm ++ ++ ++ ++ destroy ++ restart ++ destroy ++ ++ /usr/bin/qemu ++ ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c +index 7ae7f5d66..d84c148df 100644 +--- a/tests/qemuxml2argvtest.c ++++ b/tests/qemuxml2argvtest.c +@@ -1065,6 +1065,10 @@ mymain(void) + QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); + DO_TEST_FAILURE("net-hostdev-vfio-multidomain", + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); ++ DO_TEST_FAILURE("net-hostdev-fail", ++ QEMU_CAPS_NODEFCONFIG, ++ QEMU_CAPS_DEVICE_VFIO_PCI); ++ + + DO_TEST("serial-vc", NONE); + DO_TEST("serial-pty", NONE); +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuBuildInterfaceCommandLine-Move-vhostuser-handling-a-bit-further.patch b/SOURCES/libvirt-qemuBuildInterfaceCommandLine-Move-vhostuser-handling-a-bit-further.patch new file mode 100644 index 0000000..0bb86a9 --- /dev/null +++ b/SOURCES/libvirt-qemuBuildInterfaceCommandLine-Move-vhostuser-handling-a-bit-further.patch @@ -0,0 +1,116 @@ +From 620a22d4292138a3c3591df9196416bed56b0316 Mon Sep 17 00:00:00 2001 +Message-Id: <620a22d4292138a3c3591df9196416bed56b0316@dist-git> +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:04 +0100 +Subject: [PATCH] qemuBuildInterfaceCommandLine: Move vhostuser handling a bit + further + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +The idea is to have function that does some checking of the +arguments at its beginning and then have one big switch for all +the interface types it supports. Each one of them generating the +corresponding part of the command line. + +Signed-off-by: Michal Privoznik +(cherry picked from commit 4a74ccdb92fd2103392b177c38846b685e141840) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_command.c | 9 +++--- + .../qemuxml2argv-net-vhostuser-fail.xml | 36 ++++++++++++++++++++++ + tests/qemuxml2argvtest.c | 3 ++ + 3 files changed, 44 insertions(+), 4 deletions(-) + create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-fail.xml + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 1e7d9209a..a9b91213d 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -8004,15 +8004,13 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + if (!bootindex) + bootindex = net->info.bootIndex; + +- if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) +- return qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps, bootindex); +- + /* Currently nothing besides TAP devices supports multiqueue. */ + if (net->driver.virtio.queues > 0 && + !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || + actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || + actualType == VIR_DOMAIN_NET_TYPE_DIRECT || +- actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) { ++ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET || ++ actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Multiqueue network is not supported for: %s"), + virDomainNetTypeToString(actualType)); +@@ -8092,6 +8090,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + */ + ret = 0; + goto cleanup; ++ } else if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) { ++ ret = qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps, bootindex); ++ goto cleanup; + } + + /* For types whose implementations use a netdev on the host, add +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-fail.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-fail.xml +new file mode 100644 +index 000000000..e9fe14f75 +--- /dev/null ++++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-fail.xml +@@ -0,0 +1,36 @@ ++ ++ QEMUGuest1 ++ c7a5fdbd-edaf-9455-926a-d65c16db1809 ++ 219136 ++ 219136 ++ 1 ++ ++ hvm ++ ++ ++ ++ destroy ++ restart ++ destroy ++ ++ /usr/bin/qemu ++ ++ ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c +index d84c148df..f48632b70 100644 +--- a/tests/qemuxml2argvtest.c ++++ b/tests/qemuxml2argvtest.c +@@ -1028,6 +1028,9 @@ mymain(void) + DO_TEST("net-vhostuser-multiq", + QEMU_CAPS_NETDEV, QEMU_CAPS_VHOSTUSER_MULTIQUEUE); + DO_TEST_FAILURE("net-vhostuser-multiq", QEMU_CAPS_NETDEV); ++ DO_TEST_FAILURE("net-vhostuser-fail", ++ QEMU_CAPS_NETDEV, ++ QEMU_CAPS_VHOSTUSER_MULTIQUEUE); + DO_TEST("net-user", NONE); + DO_TEST("net-virtio", NONE); + DO_TEST("net-virtio-device", +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuBuildVhostuserCommandLine-Reuse-qemuBuildChrChardevStr.patch b/SOURCES/libvirt-qemuBuildVhostuserCommandLine-Reuse-qemuBuildChrChardevStr.patch new file mode 100644 index 0000000..e33e0cc --- /dev/null +++ b/SOURCES/libvirt-qemuBuildVhostuserCommandLine-Reuse-qemuBuildChrChardevStr.patch @@ -0,0 +1,173 @@ +From 6a085ddb32e48aad09d6a831c02bfd531ac048af Mon Sep 17 00:00:00 2001 +Message-Id: <6a085ddb32e48aad09d6a831c02bfd531ac048af@dist-git> +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:10 +0100 +Subject: [PATCH] qemuBuildVhostuserCommandLine: Reuse qemuBuildChrChardevStr + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +There's no need to reinvent the wheel here. We already have a +function to format virDomainChrSourceDefPtr. It's called +qemuBuildChrChardevStr(). Use that instead of some dummy +virBufferAsprintf(). + +Signed-off-by: Michal Privoznik +(cherry picked from commit 0c61cf315859a74326da93bbb6f04a08509ef91e) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_command.c | 45 ++++++++++++++++++++++++++------------------- + 1 file changed, 26 insertions(+), 19 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index d28a367cc..b99fb7a8f 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -7908,13 +7908,16 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg, + } + + static int +-qemuBuildVhostuserCommandLine(virCommandPtr cmd, ++qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, ++ virLogManagerPtr logManager, ++ virCommandPtr cmd, + virDomainDefPtr def, + virDomainNetDefPtr net, + virQEMUCapsPtr qemuCaps, + unsigned int bootindex) + { +- virBuffer chardev_buf = VIR_BUFFER_INITIALIZER; ++ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); ++ char *chardev = NULL; + virBuffer netdev_buf = VIR_BUFFER_INITIALIZER; + unsigned int queues = net->driver.virtio.queues; + char *nic = NULL; +@@ -7927,9 +7930,10 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd, + + switch ((virDomainChrType) net->data.vhostuser->type) { + case VIR_DOMAIN_CHR_TYPE_UNIX: +- virBufferAsprintf(&chardev_buf, "socket,id=char%s,path=%s%s", +- net->info.alias, net->data.vhostuser->data.nix.path, +- net->data.vhostuser->data.nix.listen ? ",server" : ""); ++ if (!(chardev = qemuBuildChrChardevStr(logManager, cmd, cfg, def, ++ net->data.vhostuser, ++ net->info.alias, qemuCaps, false))) ++ goto error; + break; + + case VIR_DOMAIN_CHR_TYPE_NULL: +@@ -7947,7 +7951,7 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd, + case VIR_DOMAIN_CHR_TYPE_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("vhost-user type '%s' not supported"), +- virDomainChrTypeToString(net->data.vhostuser->type)); ++ virDomainChrTypeToString(net->data.vhostuser->type)); + goto error; + } + +@@ -7965,7 +7969,8 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd, + } + + virCommandAddArg(cmd, "-chardev"); +- virCommandAddArgBuffer(cmd, &chardev_buf); ++ virCommandAddArg(cmd, chardev); ++ VIR_FREE(chardev); + + virCommandAddArg(cmd, "-netdev"); + virCommandAddArgBuffer(cmd, &netdev_buf); +@@ -7979,11 +7984,13 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd, + + virCommandAddArgList(cmd, "-device", nic, NULL); + VIR_FREE(nic); ++ virObjectUnref(cfg); + + return 0; + + error: +- virBufferFreeAndReset(&chardev_buf); ++ virObjectUnref(cfg); ++ VIR_FREE(chardev); + virBufferFreeAndReset(&netdev_buf); + VIR_FREE(nic); + +@@ -7991,8 +7998,9 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd, + } + + static int +-qemuBuildInterfaceCommandLine(virCommandPtr cmd, +- virQEMUDriverPtr driver, ++qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, ++ virLogManagerPtr logManager, ++ virCommandPtr cmd, + virDomainDefPtr def, + virDomainNetDefPtr net, + virQEMUCapsPtr qemuCaps, +@@ -8012,7 +8020,6 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + char **tapfdName = NULL; + char **vhostfdName = NULL; + virDomainNetType actualType = virDomainNetGetActualType(net); +- virQEMUDriverConfigPtr cfg = NULL; + virNetDevBandwidthPtr actualBandwidth; + size_t i; + +@@ -8055,8 +8062,6 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + return -1; + } + +- cfg = virQEMUDriverGetConfig(driver); +- + switch (actualType) { + case VIR_DOMAIN_NET_TYPE_NETWORK: + case VIR_DOMAIN_NET_TYPE_BRIDGE: +@@ -8116,7 +8121,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + break; + + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: +- ret = qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps, bootindex); ++ ret = qemuBuildVhostuserCommandLine(driver, logManager, cmd, def, ++ net, qemuCaps, bootindex); + goto cleanup; + break; + +@@ -8289,7 +8295,6 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + VIR_FREE(host); + VIR_FREE(tapfdName); + VIR_FREE(vhostfdName); +- virObjectUnref(cfg); + return ret; + } + +@@ -8299,8 +8304,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + * API domainSetSecurityTapFDLabel that doesn't use the const format. + */ + static int +-qemuBuildNetCommandLine(virCommandPtr cmd, +- virQEMUDriverPtr driver, ++qemuBuildNetCommandLine(virQEMUDriverPtr driver, ++ virLogManagerPtr logManager, ++ virCommandPtr cmd, + virDomainDefPtr def, + virQEMUCapsPtr qemuCaps, + virNetDevVPortProfileOp vmop, +@@ -8339,7 +8345,7 @@ qemuBuildNetCommandLine(virCommandPtr cmd, + else + vlan = i; + +- if (qemuBuildInterfaceCommandLine(cmd, driver, def, net, ++ if (qemuBuildInterfaceCommandLine(driver, logManager, cmd, def, net, + qemuCaps, vlan, bootNet, vmop, + standalone, nnicindexes, + nicindexes) < 0) +@@ -9672,7 +9678,8 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, + if (qemuBuildFSDevCommandLine(cmd, def, qemuCaps) < 0) + goto error; + +- if (qemuBuildNetCommandLine(cmd, driver, def, qemuCaps, vmop, standalone, ++ if (qemuBuildNetCommandLine(driver, logManager, cmd, def, ++ qemuCaps, vmop, standalone, + emitBootindex, nnicindexes, nicindexes, + &bootHostdevNet) < 0) + goto error; +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuBuildVhostuserCommandLine-Unify-netdev-creation.patch b/SOURCES/libvirt-qemuBuildVhostuserCommandLine-Unify-netdev-creation.patch new file mode 100644 index 0000000..9b1a29c --- /dev/null +++ b/SOURCES/libvirt-qemuBuildVhostuserCommandLine-Unify-netdev-creation.patch @@ -0,0 +1,83 @@ +From 540c7a0b9ff298f88c0c21ba6d0afbd47ac90a78 Mon Sep 17 00:00:00 2001 +Message-Id: <540c7a0b9ff298f88c0c21ba6d0afbd47ac90a78@dist-git> +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:11 +0100 +Subject: [PATCH] qemuBuildVhostuserCommandLine: Unify -netdev creation + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +Currently, what we do for vhost-user network is generate the +following part of command line: + +-netdev type=vhost-user,id=hostnet0,chardev=charnet0 + +There's no need for 'type=' it is the default. Drop it. + +Signed-off-by: Michal Privoznik +(cherry picked from commit b093e8522483c689e6ffaf7bdef98991f862c88b) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_command.c | 2 +- + tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args | 6 +++--- + tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args | 4 ++-- + 3 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index b99fb7a8f..aa289ad64 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -7955,7 +7955,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, + goto error; + } + +- virBufferAsprintf(&netdev_buf, "type=vhost-user,id=host%s,chardev=char%s", ++ virBufferAsprintf(&netdev_buf, "vhost-user,id=host%s,chardev=char%s", + net->info.alias, net->info.alias); + + if (queues > 1) { +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args +index a136dbab6..48930ef16 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args ++++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args +@@ -20,16 +20,16 @@ QEMU_AUDIO_DRV=none \ + -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ + -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ + -chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \ +--netdev type=vhost-user,id=hostnet0,chardev=charnet0 \ ++-netdev vhost-user,id=hostnet0,chardev=charnet0 \ + -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\ + addr=0x3 \ + -chardev socket,id=charnet1,path=/tmp/vhost1.sock \ +--netdev type=vhost-user,id=hostnet1,chardev=charnet1 \ ++-netdev vhost-user,id=hostnet1,chardev=charnet1 \ + -device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,\ + addr=0x4 \ + -netdev socket,listen=:2015,id=hostnet2 \ + -device rtl8139,netdev=hostnet2,id=net2,mac=52:54:00:95:db:c0,bus=pci.0,addr=0x5 \ + -chardev socket,id=charnet3,path=/tmp/vhost2.sock \ +--netdev type=vhost-user,id=hostnet3,chardev=charnet3,queues=4 \ ++-netdev vhost-user,id=hostnet3,chardev=charnet3,queues=4 \ + -device virtio-net-pci,mq=on,vectors=10,netdev=hostnet3,id=net3,\ + mac=52:54:00:ee:96:6d,bus=pci.0,addr=0x6 +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args +index 8356ef0c7..f4dc9d573 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args ++++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args +@@ -20,11 +20,11 @@ QEMU_AUDIO_DRV=none \ + -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ + -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ + -chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \ +--netdev type=vhost-user,id=hostnet0,chardev=charnet0 \ ++-netdev vhost-user,id=hostnet0,chardev=charnet0 \ + -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\ + addr=0x3 \ + -chardev socket,id=charnet1,path=/tmp/vhost1.sock \ +--netdev type=vhost-user,id=hostnet1,chardev=charnet1 \ ++-netdev vhost-user,id=hostnet1,chardev=charnet1 \ + -device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,\ + addr=0x4 \ + -netdev socket,listen=:2015,id=hostnet2 \ +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuDomainAttachNetDevice-Avoid-originalError-leak.patch b/SOURCES/libvirt-qemuDomainAttachNetDevice-Avoid-originalError-leak.patch new file mode 100644 index 0000000..a517126 --- /dev/null +++ b/SOURCES/libvirt-qemuDomainAttachNetDevice-Avoid-originalError-leak.patch @@ -0,0 +1,82 @@ +From a52fbab4f76d05c3764dad87333c0cefd0004e8f Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Thu, 22 Dec 2016 14:23:05 +0100 +Subject: [PATCH] qemuDomainAttachNetDevice: Avoid @originalError leak + +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1404186 + +Coverity identified that this variable might be leaked. And it's +right. If an error occurred and we have to roll back the control +jumps to try_remove label where we save the current error (see +0e82fa4c34 for more info). However, inside the code a jump onto +other label is possible thus leaking the error object. + +Signed-off-by: Michal Privoznik +(cherry picked from commit ca1ac6643e8b466487597f981fad15abc5f336b4) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_hotplug.c | 42 +++++++++++++++++++++--------------------- + 1 file changed, 21 insertions(+), 21 deletions(-) + +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index 62e275e94..58d25ca0e 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -1279,32 +1279,32 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + if (vlan < 0) { + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { + char *netdev_name; +- if (virAsprintf(&netdev_name, "host%s", net->info.alias) < 0) +- goto cleanup; +- qemuDomainObjEnterMonitor(driver, vm); +- if (charDevPlugged && +- qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0) +- VIR_WARN("Failed to remove associated chardev %s", charDevAlias); +- if (netdevPlugged && +- qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0) +- VIR_WARN("Failed to remove network backend for netdev %s", +- netdev_name); +- ignore_value(qemuDomainObjExitMonitor(driver, vm)); +- VIR_FREE(netdev_name); ++ if (virAsprintf(&netdev_name, "host%s", net->info.alias) >= 0) { ++ qemuDomainObjEnterMonitor(driver, vm); ++ if (charDevPlugged && ++ qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0) ++ VIR_WARN("Failed to remove associated chardev %s", charDevAlias); ++ if (netdevPlugged && ++ qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0) ++ VIR_WARN("Failed to remove network backend for netdev %s", ++ netdev_name); ++ ignore_value(qemuDomainObjExitMonitor(driver, vm)); ++ VIR_FREE(netdev_name); ++ } + } else { + VIR_WARN("Unable to remove network backend"); + } + } else { + char *hostnet_name; +- if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0) +- goto cleanup; +- qemuDomainObjEnterMonitor(driver, vm); +- if (hostPlugged && +- qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) +- VIR_WARN("Failed to remove network backend for vlan %d, net %s", +- vlan, hostnet_name); +- ignore_value(qemuDomainObjExitMonitor(driver, vm)); +- VIR_FREE(hostnet_name); ++ if (virAsprintf(&hostnet_name, "host%s", net->info.alias) >= 0) { ++ qemuDomainObjEnterMonitor(driver, vm); ++ if (hostPlugged && ++ qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) ++ VIR_WARN("Failed to remove network backend for vlan %d, net %s", ++ vlan, hostnet_name); ++ ignore_value(qemuDomainObjExitMonitor(driver, vm)); ++ VIR_FREE(hostnet_name); ++ } + } + virSetError(originalError); + virFreeError(originalError); +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuDomainAttachNetDevice-Don-t-overwrite-error-on-rollback.patch b/SOURCES/libvirt-qemuDomainAttachNetDevice-Don-t-overwrite-error-on-rollback.patch new file mode 100644 index 0000000..315ef1a --- /dev/null +++ b/SOURCES/libvirt-qemuDomainAttachNetDevice-Don-t-overwrite-error-on-rollback.patch @@ -0,0 +1,54 @@ +From f87f0fc731dcb28cfcbe65bb7a69628f431030aa Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Thu, 15 Dec 2016 18:17:45 +0100 +Subject: [PATCH] qemuDomainAttachNetDevice: Don't overwrite error on rollback + +RHEL-7.4: https://bugzilla.redhat.com/show_bug.cgi?id=1386976 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1404186 + +If there is an error hotpluging a net device (for whatever +reason) a rollback operation is performed. However, whilst doing +so various helper functions that are called report errors on +their own. This results in the original error to be overwritten +and thus misleading the user. + +Signed-off-by: Michal Privoznik +(cherry picked from commit 0e82fa4c345acb7ad52e0da0e54f7375eda57657) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_hotplug.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index 8acbf370b..573cb8c93 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -885,6 +885,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + virDomainNetDefPtr net) + { + qemuDomainObjPrivatePtr priv = vm->privateData; ++ virErrorPtr originalError = NULL; + char **tapfdName = NULL; + int *tapfd = NULL; + size_t tapfdSize = 0; +@@ -1266,6 +1267,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + if (!virDomainObjIsActive(vm)) + goto cleanup; + ++ originalError = virSaveLastError(); + if (vlan < 0) { + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { + char *netdev_name; +@@ -1296,6 +1298,8 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + VIR_FREE(hostnet_name); + } ++ virSetError(originalError); ++ virFreeError(originalError); + goto cleanup; + } + +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuDomainAttachNetDevice-Enable-multiqueue-for-vhost-user.patch b/SOURCES/libvirt-qemuDomainAttachNetDevice-Enable-multiqueue-for-vhost-user.patch new file mode 100644 index 0000000..92eb624 --- /dev/null +++ b/SOURCES/libvirt-qemuDomainAttachNetDevice-Enable-multiqueue-for-vhost-user.patch @@ -0,0 +1,36 @@ +From 6e6c57bacc0072c0ca152280c7a37340be76787a Mon Sep 17 00:00:00 2001 +Message-Id: <6e6c57bacc0072c0ca152280c7a37340be76787a@dist-git> +From: Michal Privoznik +Date: Thu, 15 Dec 2016 18:17:46 +0100 +Subject: [PATCH] qemuDomainAttachNetDevice: Enable multiqueue for vhost-user + +RHEL-7.4: https://bugzilla.redhat.com/show_bug.cgi?id=1386976 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1404186 + +We have everything ready. Actually the only limitation was our +check that denied hotplug of vhost-user. + +Signed-off-by: Michal Privoznik +(cherry picked from commit 21db4ab0528ca6c78744148ca4b7515aaeb4d0bf) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_hotplug.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index 573cb8c93..7e4a653e6 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -926,7 +926,8 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || + actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || + actualType == VIR_DOMAIN_NET_TYPE_DIRECT || +- actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) { ++ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET || ++ actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Multiqueue network is not supported for: %s"), + virDomainNetTypeToString(actualType)); +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuDomainAttachNetDevice-Explicitly-list-allowed-types-for-hotplug.patch b/SOURCES/libvirt-qemuDomainAttachNetDevice-Explicitly-list-allowed-types-for-hotplug.patch new file mode 100644 index 0000000..0aadaa9 --- /dev/null +++ b/SOURCES/libvirt-qemuDomainAttachNetDevice-Explicitly-list-allowed-types-for-hotplug.patch @@ -0,0 +1,105 @@ +From da8bc106ac11a4b90f1559c3f34a1f0829a61506 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:07 +0100 +Subject: [PATCH] qemuDomainAttachNetDevice: Explicitly list allowed types for + hotplug + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +Instead of blindly claim support for hot-plugging of every +interface type out there we should copy approach we have for +device types: white listing supported types and explicitly error +out on unsupported ones. +For instance, trying to hotplug vhostuser interface results in +nothing usable from guest currently. vhostuser typed interfaces +require additional work on our side. + +Signed-off-by: Michal Privoznik +(cherry picked from commit c266b6044003ac2f10f4cd15e58164d629508ccb) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_hotplug.c | 33 +++++++++++++++++++++++++++------ + 1 file changed, 27 insertions(+), 6 deletions(-) + +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index ca2d89702..011152762 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -940,8 +940,9 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + return -1; + } + +- if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || +- actualType == VIR_DOMAIN_NET_TYPE_NETWORK) { ++ switch (actualType) { ++ case VIR_DOMAIN_NET_TYPE_BRIDGE: ++ case VIR_DOMAIN_NET_TYPE_NETWORK: + tapfdSize = vhostfdSize = net->driver.virtio.queues; + if (!tapfdSize) + tapfdSize = vhostfdSize = 1; +@@ -958,7 +959,9 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + if (qemuInterfaceOpenVhostNet(vm->def, net, priv->qemuCaps, + vhostfd, &vhostfdSize) < 0) + goto cleanup; +- } else if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) { ++ break; ++ ++ case VIR_DOMAIN_NET_TYPE_DIRECT: + tapfdSize = vhostfdSize = net->driver.virtio.queues; + if (!tapfdSize) + tapfdSize = vhostfdSize = 1; +@@ -976,7 +979,9 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + if (qemuInterfaceOpenVhostNet(vm->def, net, priv->qemuCaps, + vhostfd, &vhostfdSize) < 0) + goto cleanup; +- } else if (actualType == VIR_DOMAIN_NET_TYPE_ETHERNET) { ++ break; ++ ++ case VIR_DOMAIN_NET_TYPE_ETHERNET: + tapfdSize = vhostfdSize = net->driver.virtio.queues; + if (!tapfdSize) + tapfdSize = vhostfdSize = 1; +@@ -987,13 +992,15 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + goto cleanup; + memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize); + if (qemuInterfaceEthernetConnect(vm->def, driver, net, +- tapfd, tapfdSize) < 0) ++ tapfd, tapfdSize) < 0) + goto cleanup; + iface_connected = true; + if (qemuInterfaceOpenVhostNet(vm->def, net, priv->qemuCaps, + vhostfd, &vhostfdSize) < 0) + goto cleanup; +- } else if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { ++ break; ++ ++ case VIR_DOMAIN_NET_TYPE_HOSTDEV: + /* This is really a "smart hostdev", so it should be attached + * as a hostdev (the hostdev code will reach over into the + * netdev-specific code as appropriate), then also added to +@@ -1005,6 +1012,20 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + ret = qemuDomainAttachHostDevice(NULL, driver, vm, + virDomainNetGetActualHostdev(net)); + goto cleanup; ++ break; ++ ++ case VIR_DOMAIN_NET_TYPE_USER: ++ case VIR_DOMAIN_NET_TYPE_VHOSTUSER: ++ case VIR_DOMAIN_NET_TYPE_SERVER: ++ case VIR_DOMAIN_NET_TYPE_CLIENT: ++ case VIR_DOMAIN_NET_TYPE_MCAST: ++ case VIR_DOMAIN_NET_TYPE_INTERNAL: ++ case VIR_DOMAIN_NET_TYPE_UDP: ++ case VIR_DOMAIN_NET_TYPE_LAST: ++ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, ++ _("hotplug of interface type of %s is not implemented yet"), ++ virDomainNetTypeToString(actualType)); ++ goto cleanup; + } + + /* Set device online immediately */ +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuDomainAttachNetDevice-Move-hostdev-handling-a-bit-further.patch b/SOURCES/libvirt-qemuDomainAttachNetDevice-Move-hostdev-handling-a-bit-further.patch new file mode 100644 index 0000000..53b1d9a --- /dev/null +++ b/SOURCES/libvirt-qemuDomainAttachNetDevice-Move-hostdev-handling-a-bit-further.patch @@ -0,0 +1,68 @@ +From d3d5bc437539aeaf88783636bfc24be554d2aa6a Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:06 +0100 +Subject: [PATCH] qemuDomainAttachNetDevice: Move hostdev handling a bit + further + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +The idea is to have function that does some checking at its +beginning and then have one big switch for all the interface +types it supports. + +Signed-off-by: Michal Privoznik +(cherry picked from commit 5b65d772dd909d9b1ded07a86304229674ebf4ac) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_hotplug.c | 26 ++++++++++++-------------- + 1 file changed, 12 insertions(+), 14 deletions(-) + +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index 4a3e97b58..ca2d89702 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -916,20 +916,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + + actualType = virDomainNetGetActualType(net); + +- if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { +- /* This is really a "smart hostdev", so it should be attached +- * as a hostdev (the hostdev code will reach over into the +- * netdev-specific code as appropriate), then also added to +- * the nets list (see cleanup:) if successful. +- * +- * qemuDomainAttachHostDevice uses a connection to resolve +- * a SCSI hostdev secret, which is not this case, so pass NULL. +- */ +- ret = qemuDomainAttachHostDevice(NULL, driver, vm, +- virDomainNetGetActualHostdev(net)); +- goto cleanup; +- } +- + /* Currently only TAP/macvtap devices supports multiqueue. */ + if (net->driver.virtio.queues > 0 && + !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || +@@ -1007,6 +993,18 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + if (qemuInterfaceOpenVhostNet(vm->def, net, priv->qemuCaps, + vhostfd, &vhostfdSize) < 0) + goto cleanup; ++ } else if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { ++ /* This is really a "smart hostdev", so it should be attached ++ * as a hostdev (the hostdev code will reach over into the ++ * netdev-specific code as appropriate), then also added to ++ * the nets list (see cleanup:) if successful. ++ * ++ * qemuDomainAttachHostDevice uses a connection to resolve ++ * a SCSI hostdev secret, which is not this case, so pass NULL. ++ */ ++ ret = qemuDomainAttachHostDevice(NULL, driver, vm, ++ virDomainNetGetActualHostdev(net)); ++ goto cleanup; + } + + /* Set device online immediately */ +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemuDomainAttachNetDevice-pass-mq-and-vectors-for-vhost-user-with-multiqueue.patch b/SOURCES/libvirt-qemuDomainAttachNetDevice-pass-mq-and-vectors-for-vhost-user-with-multiqueue.patch new file mode 100644 index 0000000..6049df2 --- /dev/null +++ b/SOURCES/libvirt-qemuDomainAttachNetDevice-pass-mq-and-vectors-for-vhost-user-with-multiqueue.patch @@ -0,0 +1,82 @@ +From 9e58c2baa75edb40ec0176c81c32081c10ed8967 Mon Sep 17 00:00:00 2001 +Message-Id: <9e58c2baa75edb40ec0176c81c32081c10ed8967@dist-git> +From: gaohaifeng +Date: Thu, 15 Dec 2016 18:17:47 +0100 +Subject: [PATCH] qemuDomainAttachNetDevice: pass mq and vectors for vhost-user + with multiqueue + +RHEL-7.4: https://bugzilla.redhat.com/show_bug.cgi?id=1386976 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1404186 + +Two reasons: +1.in none hotplug, we will pass it. We can see from libvirt function +qemuBuildVhostuserCommandLine +2.qemu will use this vetcor num to init msix table. If we don't pass, qemu +will use default value, this will cause VM can only use default value +interrupts at most. + +Signed-off-by: gaohaifeng +(cherry picked from commit f81b33b50c6cad384d32067c8e28f404f54a530d) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_hotplug.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index 7e4a653e6..62e275e94 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -892,6 +892,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + char **vhostfdName = NULL; + int *vhostfd = NULL; + size_t vhostfdSize = 0; ++ size_t queueSize = 0; + char *nicstr = NULL; + char *netstr = NULL; + virNetDevVPortProfilePtr vport = NULL; +@@ -955,6 +956,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + tapfdSize = vhostfdSize = net->driver.virtio.queues; + if (!tapfdSize) + tapfdSize = vhostfdSize = 1; ++ queueSize = tapfdSize; + if (VIR_ALLOC_N(tapfd, tapfdSize) < 0) + goto cleanup; + memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); +@@ -974,6 +976,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + tapfdSize = vhostfdSize = net->driver.virtio.queues; + if (!tapfdSize) + tapfdSize = vhostfdSize = 1; ++ queueSize = tapfdSize; + if (VIR_ALLOC_N(tapfd, tapfdSize) < 0) + goto cleanup; + memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); +@@ -994,6 +997,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + tapfdSize = vhostfdSize = net->driver.virtio.queues; + if (!tapfdSize) + tapfdSize = vhostfdSize = 1; ++ queueSize = tapfdSize; + if (VIR_ALLOC_N(tapfd, tapfdSize) < 0) + goto cleanup; + memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); +@@ -1024,6 +1028,9 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + break; + + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: ++ queueSize = net->driver.virtio.queues; ++ if (!queueSize) ++ queueSize = 1; + if (!qemuDomainSupportsNetdev(vm->def, priv->qemuCaps, net)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Netdev support unavailable")); +@@ -1166,7 +1173,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + VIR_FORCE_CLOSE(vhostfd[i]); + + if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0, +- vhostfdSize, priv->qemuCaps))) ++ queueSize, priv->qemuCaps))) + goto try_remove; + + qemuDomainObjEnterMonitor(driver, vm); +-- +2.11.0 + diff --git a/SOURCES/libvirt-qemu_hotplug-Support-interface-type-of-vhost-user-hotplug.patch b/SOURCES/libvirt-qemu_hotplug-Support-interface-type-of-vhost-user-hotplug.patch new file mode 100644 index 0000000..75e32b6 --- /dev/null +++ b/SOURCES/libvirt-qemu_hotplug-Support-interface-type-of-vhost-user-hotplug.patch @@ -0,0 +1,218 @@ +From 6ad2b5b70219158aa873058b4d4b1d94c481640d Mon Sep 17 00:00:00 2001 +Message-Id: <6ad2b5b70219158aa873058b4d4b1d94c481640d@dist-git> +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:13 +0100 +Subject: [PATCH] qemu_hotplug: Support interface type of vhost-user hotplug + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +There are couple of things that needs to be done in order to +allow vhost-user hotplug. Firstly, vhost-user requires a chardev +which is connected to vhost-user bridge and through which qemu +communicates with the bridge (no acutal guest traffic is sent +through there, just some metadata). In order to generate proper +chardev alias, we must assign device alias way sooner. + +Then, because we are plugging the chardev first, we need to do +the proper undo if something fails - that is remove netdev too. +We don't want anything to be left over in case attach fails at +some point. + +Signed-off-by: Michal Privoznik +(cherry picked from commit ff89d5cbcf266e780b4ff93960969b3a6c2e9a01) +Signed-off-by: Michal Privoznik +--- + src/qemu/qemu_hotplug.c | 71 +++++++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 60 insertions(+), 11 deletions(-) + +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index 011152762..8acbf370b 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -902,6 +902,10 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + virNetDevBandwidthPtr actualBandwidth; + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + size_t i; ++ char *charDevAlias = NULL; ++ bool charDevPlugged = false; ++ bool netdevPlugged = false; ++ bool hostPlugged = false; + + /* preallocate new slot for device */ + if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0) +@@ -940,6 +944,9 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + return -1; + } + ++ if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0) ++ goto cleanup; ++ + switch (actualType) { + case VIR_DOMAIN_NET_TYPE_BRIDGE: + case VIR_DOMAIN_NET_TYPE_NETWORK: +@@ -1014,8 +1021,18 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + goto cleanup; + break; + +- case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: ++ if (!qemuDomainSupportsNetdev(vm->def, priv->qemuCaps, net)) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ "%s", _("Netdev support unavailable")); ++ goto cleanup; ++ } ++ ++ if (virAsprintf(&charDevAlias, "char%s", net->info.alias) < 0) ++ goto cleanup; ++ break; ++ ++ case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: +@@ -1051,9 +1068,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + goto cleanup; + } + +- if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0) +- goto cleanup; +- + if (qemuDomainMachineIsS390CCW(vm->def) && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { + net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; +@@ -1111,23 +1125,36 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + } + + qemuDomainObjEnterMonitor(driver, vm); ++ ++ if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) { ++ if (qemuMonitorAttachCharDev(priv->mon, charDevAlias, net->data.vhostuser) < 0) { ++ ignore_value(qemuDomainObjExitMonitor(driver, vm)); ++ virDomainAuditNet(vm, NULL, net, "attach", false); ++ goto cleanup; ++ } ++ charDevPlugged = true; ++ } ++ + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { + if (qemuMonitorAddNetdev(priv->mon, netstr, + tapfd, tapfdName, tapfdSize, + vhostfd, vhostfdName, vhostfdSize) < 0) { + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + virDomainAuditNet(vm, NULL, net, "attach", false); +- goto cleanup; ++ goto try_remove; + } ++ netdevPlugged = true; + } else { + if (qemuMonitorAddHostNetwork(priv->mon, netstr, + tapfd, tapfdName, tapfdSize, + vhostfd, vhostfdName, vhostfdSize) < 0) { + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + virDomainAuditNet(vm, NULL, net, "attach", false); +- goto cleanup; ++ goto try_remove; + } ++ hostPlugged = true; + } ++ + if (qemuDomainObjExitMonitor(driver, vm) < 0) + goto cleanup; + +@@ -1230,6 +1257,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + } + VIR_FREE(vhostfd); + VIR_FREE(vhostfdName); ++ VIR_FREE(charDevAlias); + virObjectUnref(cfg); + + return ret; +@@ -1244,7 +1272,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + if (virAsprintf(&netdev_name, "host%s", net->info.alias) < 0) + goto cleanup; + qemuDomainObjEnterMonitor(driver, vm); +- if (qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0) ++ if (charDevPlugged && ++ qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0) ++ VIR_WARN("Failed to remove associated chardev %s", charDevAlias); ++ if (netdevPlugged && ++ qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0) + VIR_WARN("Failed to remove network backend for netdev %s", + netdev_name); + ignore_value(qemuDomainObjExitMonitor(driver, vm)); +@@ -1257,7 +1289,8 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0) + goto cleanup; + qemuDomainObjEnterMonitor(driver, vm); +- if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) ++ if (hostPlugged && ++ qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) + VIR_WARN("Failed to remove network backend for vlan %d, net %s", + vlan, hostnet_name); + ignore_value(qemuDomainObjExitMonitor(driver, vm)); +@@ -3357,10 +3390,12 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, + virNetDevVPortProfilePtr vport; + virObjectEventPtr event; + char *hostnet_name = NULL; ++ char *charDevAlias = NULL; + size_t i; + int ret = -1; ++ int actualType = virDomainNetGetActualType(net); + +- if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV) { ++ if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { + /* this function handles all hostdev and netdev cleanup */ + ret = qemuDomainRemoveHostDevice(driver, vm, + virDomainNetGetActualHostdev(net)); +@@ -3370,9 +3405,11 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, + VIR_DEBUG("Removing network interface %s from domain %p %s", + net->info.alias, vm, vm->def->name); + +- if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0) ++ if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0 || ++ virAsprintf(&charDevAlias, "char%s", net->info.alias) < 0) + goto cleanup; + ++ + qemuDomainObjEnterMonitor(driver, vm); + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { + if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) { +@@ -3395,6 +3432,17 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, + goto cleanup; + } + } ++ ++ if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) { ++ /* vhostuser has a chardev too */ ++ if (qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0) { ++ /* well, this is a messy situation. Guest visible PCI device has ++ * been removed, netdev too but chardev not. The best seems to be ++ * to just ignore the error and carry on. ++ */ ++ } ++ } ++ + if (qemuDomainObjExitMonitor(driver, vm) < 0) + goto cleanup; + +@@ -3419,7 +3467,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, + &net->mac)); + } + +- if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) { ++ if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) { + ignore_value(virNetDevMacVLanDeleteWithVPortProfile( + net->ifname, &net->mac, + virDomainNetGetActualDirectDev(net), +@@ -3445,6 +3493,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, + + cleanup: + virObjectUnref(cfg); ++ VIR_FREE(charDevAlias); + VIR_FREE(hostnet_name); + return ret; + } +-- +2.11.0 + diff --git a/SOURCES/libvirt-virDomainNetDefParseXML-Realign.patch b/SOURCES/libvirt-virDomainNetDefParseXML-Realign.patch new file mode 100644 index 0000000..61ecbd1 --- /dev/null +++ b/SOURCES/libvirt-virDomainNetDefParseXML-Realign.patch @@ -0,0 +1,49 @@ +From 3457bed5d7caab62046ae6bc6dc70d152071d1f0 Mon Sep 17 00:00:00 2001 +Message-Id: <3457bed5d7caab62046ae6bc6dc70d152071d1f0@dist-git> +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:01 +0100 +Subject: [PATCH] virDomainNetDefParseXML: Realign + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +There are couple of formatting issues. No functional change +though. + +Signed-off-by: Michal Privoznik +(cherry picked from commit 94a10de26b1fa999dbb67cfeea8e3339205d9db6) +Signed-off-by: Michal Privoznik +--- + src/conf/domain_conf.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 514e50d3b..23e447a4e 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -9202,8 +9202,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, + ifname = virXMLPropString(cur, "dev"); + if (ifname && + (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && +- (STRPREFIX(ifname, VIR_NET_GENERATED_PREFIX) || +- (prefix && STRPREFIX(ifname, prefix)))) { ++ (STRPREFIX(ifname, VIR_NET_GENERATED_PREFIX) || ++ (prefix && STRPREFIX(ifname, prefix)))) { + /* An auto-generated target name, blank it out */ + VIR_FREE(ifname); + } +@@ -9764,9 +9764,9 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, + filter = NULL; + def->filterparams = filterparams; + filterparams = NULL; +- break; ++ break; + default: +- break; ++ break; + } + } + +-- +2.11.0 + diff --git a/SOURCES/libvirt-virDomainNetGetActualType-Return-type-is-virDomainNetType.patch b/SOURCES/libvirt-virDomainNetGetActualType-Return-type-is-virDomainNetType.patch new file mode 100644 index 0000000..3543eea --- /dev/null +++ b/SOURCES/libvirt-virDomainNetGetActualType-Return-type-is-virDomainNetType.patch @@ -0,0 +1,237 @@ +From a9eea9b50f56334046fd21e0bc11fb878d4e6d07 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Tue, 8 Nov 2016 13:42:02 +0100 +Subject: [PATCH] virDomainNetGetActualType: Return type is virDomainNetType + +RHEL-7.3: https://bugzilla.redhat.com/show_bug.cgi?id=1366108 +RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1392032 + +This function for some weird reason returns integer instead of +virDomainNetType type. It is important to return the correct type +so that we know what values we can expect. + +Signed-off-by: Michal Privoznik +(cherry picked from commit 507032d98d390245047f69474d0671d6b0b12651) +Signed-off-by: Michal Privoznik +--- + src/bhyve/bhyve_command.c | 2 +- + src/bhyve/bhyve_process.c | 2 +- + src/conf/domain_conf.c | 8 ++++---- + src/conf/domain_conf.h | 2 +- + src/libxl/libxl_domain.c | 2 +- + src/libxl/libxl_driver.c | 2 +- + src/lxc/lxc_driver.c | 9 +++++++-- + src/qemu/qemu_command.c | 2 +- + src/qemu/qemu_hotplug.c | 4 ++-- + src/qemu/qemu_process.c | 13 ++++++++++++- + 10 files changed, 31 insertions(+), 15 deletions(-) + +diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c +index 9ad3f9b52..55ad95076 100644 +--- a/src/bhyve/bhyve_command.c ++++ b/src/bhyve/bhyve_command.c +@@ -52,7 +52,7 @@ bhyveBuildNetArgStr(const virDomainDef *def, + char macaddr[VIR_MAC_STRING_BUFLEN]; + char *realifname = NULL; + char *brname = NULL; +- int actualType = virDomainNetGetActualType(net); ++ virDomainNetType actualType = virDomainNetGetActualType(net); + + if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) { + if (VIR_STRDUP(brname, virDomainNetGetActualBridgeName(net)) < 0) +diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c +index 6db070f6b..9d8097676 100644 +--- a/src/bhyve/bhyve_process.c ++++ b/src/bhyve/bhyve_process.c +@@ -77,7 +77,7 @@ bhyveNetCleanup(virDomainObjPtr vm) + + for (i = 0; i < vm->def->nnets; i++) { + virDomainNetDefPtr net = vm->def->nets[i]; +- int actualType = virDomainNetGetActualType(net); ++ virDomainNetType actualType = virDomainNetGetActualType(net); + + if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) { + if (net->ifname) { +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 23e447a4e..da3de8299 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -20865,7 +20865,7 @@ virDomainActualNetDefContentsFormat(virBufferPtr buf, + bool inSubelement, + unsigned int flags) + { +- int actualType = virDomainNetGetActualType(def); ++ virDomainNetType actualType = virDomainNetGetActualType(def); + + if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { + if (virDomainHostdevDefFormatSubsys(buf, virDomainNetGetActualHostdev(def), +@@ -20945,7 +20945,7 @@ virDomainActualNetDefFormat(virBufferPtr buf, + virDomainNetDefPtr def, + unsigned int flags) + { +- unsigned int type; ++ virDomainNetType type; + const char *typeStr; + + if (!def) +@@ -21100,7 +21100,7 @@ virDomainNetDefFormat(virBufferPtr buf, + char *prefix, + unsigned int flags) + { +- unsigned int actualType = virDomainNetGetActualType(def); ++ virDomainNetType actualType = virDomainNetGetActualType(def); + bool publicActual = false; + const char *typeStr; + virDomainHostdevDefPtr hostdef = NULL; +@@ -24804,7 +24804,7 @@ virDomainStateReasonFromString(virDomainState state, const char *reason) + * otherwise return the value from the NetDef. + */ + +-int ++virDomainNetType + virDomainNetGetActualType(virDomainNetDefPtr iface) + { + if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index b8944cb79..84cda68b6 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -2791,7 +2791,7 @@ int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def, + const char *socket) + ATTRIBUTE_NONNULL(1); + +-int virDomainNetGetActualType(virDomainNetDefPtr iface); ++virDomainNetType virDomainNetGetActualType(virDomainNetDefPtr iface); + const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface); + int virDomainNetGetActualBridgeMACTableManager(virDomainNetDefPtr iface); + const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface); +diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c +index ca37a3375..3cd34bee2 100644 +--- a/src/libxl/libxl_domain.c ++++ b/src/libxl/libxl_domain.c +@@ -916,7 +916,7 @@ libxlNetworkPrepareDevices(virDomainDefPtr def) + + for (i = 0; i < def->nnets; i++) { + virDomainNetDefPtr net = def->nets[i]; +- int actualType; ++ virDomainNetType actualType; + + /* If appropriate, grab a physical device from the configured + * network's pool of devices, or resolve bridge device name +diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c +index 711e8013b..0224e68f4 100644 +--- a/src/libxl/libxl_driver.c ++++ b/src/libxl/libxl_driver.c +@@ -3155,7 +3155,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver, + virDomainNetDefPtr net) + { + libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); +- int actualType; ++ virDomainNetType actualType; + libxl_device_nic nic; + int ret = -1; + char mac[VIR_MAC_STRING_BUFLEN]; +diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c +index d47f21589..30e3314cd 100644 +--- a/src/lxc/lxc_driver.c ++++ b/src/lxc/lxc_driver.c +@@ -3945,7 +3945,7 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn, + { + virLXCDomainObjPrivatePtr priv = vm->privateData; + int ret = -1; +- int actualType; ++ virDomainNetType actualType; + virNetDevBandwidthPtr actualBandwidth; + char *veth = NULL; + +@@ -4032,6 +4032,10 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn, + case VIR_DOMAIN_NET_TYPE_DIRECT: + ignore_value(virNetDevMacVLanDelete(veth)); + break; ++ ++ default: ++ /* no-op */ ++ break; + } + } + +@@ -4432,7 +4436,8 @@ static int + lxcDomainDetachDeviceNetLive(virDomainObjPtr vm, + virDomainDeviceDefPtr dev) + { +- int detachidx, actualType, ret = -1; ++ int detachidx, ret = -1; ++ virDomainNetType actualType; + virDomainNetDefPtr detach = NULL; + virNetDevVPortProfilePtr vport = NULL; + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 43e1a9350..8d002ffb2 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -7995,7 +7995,7 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd, + size_t vhostfdSize = 0; + char **tapfdName = NULL; + char **vhostfdName = NULL; +- int actualType = virDomainNetGetActualType(net); ++ virDomainNetType actualType = virDomainNetGetActualType(net); + virQEMUDriverConfigPtr cfg = NULL; + virNetDevBandwidthPtr actualBandwidth; + size_t i; +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index df3764ffe..4a3e97b58 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -898,7 +898,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + int vlan; + bool releaseaddr = false; + bool iface_connected = false; +- int actualType; ++ virDomainNetType actualType; + virNetDevBandwidthPtr actualBandwidth; + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + size_t i; +@@ -2405,7 +2405,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, + virDomainNetDefPtr newdev = dev->data.net; + virDomainNetDefPtr *devslot = NULL; + virDomainNetDefPtr olddev; +- int oldType, newType; ++ virDomainNetType oldType, newType; + bool needReconnect = false; + bool needBridgeChange = false; + bool needFilterChange = false; +diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c +index e13db3877..3a21b0b90 100644 +--- a/src/qemu/qemu_process.c ++++ b/src/qemu/qemu_process.c +@@ -4571,7 +4571,7 @@ qemuProcessNetworkPrepareDevices(virDomainDefPtr def) + + for (i = 0; i < def->nnets; i++) { + virDomainNetDefPtr net = def->nets[i]; +- int actualType; ++ virDomainNetType actualType; + + /* If appropriate, grab a physical device from the configured + * network's pool of devices, or resolve bridge device name +@@ -5902,6 +5902,17 @@ void qemuProcessStop(virQEMUDriverPtr driver, + ignore_value(virNetDevTapDelete(net->ifname, net->backend.tap)); + #endif + break; ++ case VIR_DOMAIN_NET_TYPE_USER: ++ case VIR_DOMAIN_NET_TYPE_VHOSTUSER: ++ case VIR_DOMAIN_NET_TYPE_SERVER: ++ case VIR_DOMAIN_NET_TYPE_CLIENT: ++ case VIR_DOMAIN_NET_TYPE_MCAST: ++ case VIR_DOMAIN_NET_TYPE_INTERNAL: ++ case VIR_DOMAIN_NET_TYPE_HOSTDEV: ++ case VIR_DOMAIN_NET_TYPE_UDP: ++ case VIR_DOMAIN_NET_TYPE_LAST: ++ /* No special cleanup procedure for these types. */ ++ break; + } + /* release the physical device (or any other resources used by + * this interface in the network driver +-- +2.11.0 + diff --git a/SPECS/libvirt.spec b/SPECS/libvirt.spec index 438ff4b..6eb0a69 100644 --- a/SPECS/libvirt.spec +++ b/SPECS/libvirt.spec @@ -217,7 +217,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 2.0.0 -Release: 10%{?dist}.2%{?extra_release} +Release: 10%{?dist}.4%{?extra_release} License: LGPLv2+ Group: Development/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root @@ -487,6 +487,25 @@ Patch255: libvirt-qemu-Support-newer-ivshmem-device-variants.patch Patch256: libvirt-qemu-Add-support-for-hot-cold-un-plug-of-shmem-devices.patch Patch257: libvirt-qemu-Fix-double-free-when-live-attaching-shmem.patch Patch258: libvirt-qemu-Make-sure-shmem-memory-is-shared.patch +Patch259: libvirt-virDomainNetDefParseXML-Realign.patch +Patch260: libvirt-virDomainNetGetActualType-Return-type-is-virDomainNetType.patch +Patch261: libvirt-qemuBuildInterfaceCommandLine-Move-hostdev-handling-a-bit-further.patch +Patch262: libvirt-qemuBuildInterfaceCommandLine-Move-vhostuser-handling-a-bit-further.patch +Patch263: libvirt-qemuBuildInterfaceCommandLine-Move-from-if-else-forest-to-switch.patch +Patch264: libvirt-qemuDomainAttachNetDevice-Move-hostdev-handling-a-bit-further.patch +Patch265: libvirt-qemuDomainAttachNetDevice-Explicitly-list-allowed-types-for-hotplug.patch +Patch266: libvirt-qemuBuildHostNetStr-Explicitly-enumerate-net-types.patch +Patch267: libvirt-qemuBuildChrChardevStr-Introduce-nowait-argument.patch +Patch268: libvirt-qemuBuildVhostuserCommandLine-Reuse-qemuBuildChrChardevStr.patch +Patch269: libvirt-qemuBuildVhostuserCommandLine-Unify-netdev-creation.patch +Patch270: libvirt-qemuBuildHostNetStr-Support-VIR_DOMAIN_NET_TYPE_VHOSTUSER.patch +Patch271: libvirt-qemu_hotplug-Support-interface-type-of-vhost-user-hotplug.patch +Patch272: libvirt-qemu-snapshot-Don-t-attempt-to-resume-cpus-if-they-were-not-paused.patch +Patch273: libvirt-qemuDomainAttachNetDevice-Don-t-overwrite-error-on-rollback.patch +Patch274: libvirt-qemuDomainAttachNetDevice-Enable-multiqueue-for-vhost-user.patch +Patch275: libvirt-qemuDomainAttachNetDevice-pass-mq-and-vectors-for-vhost-user-with-multiqueue.patch +Patch276: libvirt-qemuDomainAttachNetDevice-Avoid-originalError-leak.patch +Patch277: libvirt-qemu-snapshot-Resume-VM-after-live-snapshot.patch Requires: libvirt-daemon = %{version}-%{release} @@ -2129,6 +2148,29 @@ exit 0 %changelog +* Thu Jan 5 2017 Jiri Denemark - 2.0.0-10.el7_3.4 +- qemuDomainAttachNetDevice: Avoid @originalError leak (rhbz#1404186) +- qemu: snapshot: Resume VM after live snapshot (rhbz#1406765) + +* Wed Dec 21 2016 Jiri Denemark - 2.0.0-10.el7_3.3 +- virDomainNetDefParseXML: Realign (rhbz#1392032) +- virDomainNetGetActualType: Return type is virDomainNetType (rhbz#1392032) +- qemuBuildInterfaceCommandLine: Move hostdev handling a bit further (rhbz#1392032) +- qemuBuildInterfaceCommandLine: Move vhostuser handling a bit further (rhbz#1392032) +- qemuBuildInterfaceCommandLine: Move from if-else forest to switch (rhbz#1392032) +- qemuDomainAttachNetDevice: Move hostdev handling a bit further (rhbz#1392032) +- qemuDomainAttachNetDevice: Explicitly list allowed types for hotplug (rhbz#1392032) +- qemuBuildHostNetStr: Explicitly enumerate net types (rhbz#1392032) +- qemuBuildChrChardevStr: Introduce @nowait argument (rhbz#1392032) +- qemuBuildVhostuserCommandLine: Reuse qemuBuildChrChardevStr (rhbz#1392032) +- qemuBuildVhostuserCommandLine: Unify -netdev creation (rhbz#1392032) +- qemuBuildHostNetStr: Support VIR_DOMAIN_NET_TYPE_VHOSTUSER (rhbz#1392032) +- qemu_hotplug: Support interface type of vhost-user hotplug (rhbz#1392032) +- qemu: snapshot: Don't attempt to resume cpus if they were not paused (rhbz#1406765) +- qemuDomainAttachNetDevice: Don't overwrite error on rollback (rhbz#1404186) +- qemuDomainAttachNetDevice: Enable multiqueue for vhost-user (rhbz#1404186) +- qemuDomainAttachNetDevice: pass mq and vectors for vhost-user with multiqueue (rhbz#1404186) + * Thu Nov 10 2016 Jiri Denemark - 2.0.0-10.el7_3.2 - qemu: Fix double free when live-attaching shmem (rhbz#1392031) - qemu: Make sure shmem memory is shared (rhbz#1392031)