[libvirt] [PATCH] qemu: fix default migration_address for NBD server
by Michael Chapman
If no migration_address is configured, QEMU will listen on 0.0.0.0 or
[::]. Commit 674afcb09e3d33500cfbbcf870ebf92cb99ecfa3 moved the
handling of this default value into a new qemuMigrationPrepareIncoming
function, however the address is also needed when starting the NBD
server from within qemuMigrationPrepareAny.
Without this commit, the nbd-server-start command fails if no explicit
migration_address is configured since libvirt passes a null value in the
listen address:
{
"execute": "nbd-server-start", "arguments": {
"addr": {
"type": "inet",
"data": { "host": null, "port": "49153" }
}
},
"id": "libvirt-14"
}
The migration address only applies to direct migration. Unfortunately we
can't move this logic as far back as qemuMigrationPrepareDirect since
QEMU's IPv6 support is only known after it has been launched.
Signed-off-by: Michael Chapman <mike(a)very.puzzling.org>
---
src/qemu/qemu_migration.c | 79 +++++++++++++++++++++++------------------------
1 file changed, 38 insertions(+), 41 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 4519aef..3f83b57 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3307,54 +3307,14 @@ qemuMigrationPrepareIncoming(virDomainObjPtr vm,
if (VIR_STRDUP(migrateFrom, "stdio") < 0)
goto cleanup;
} else {
- bool encloseAddress = false;
- bool hostIPv6Capable = false;
- bool qemuIPv6Capable = false;
- struct addrinfo *info = NULL;
- struct addrinfo hints = { .ai_flags = AI_ADDRCONFIG,
- .ai_socktype = SOCK_STREAM };
const char *incFormat;
- if (getaddrinfo("::", NULL, &hints, &info) == 0) {
- freeaddrinfo(info);
- hostIPv6Capable = true;
- }
- qemuIPv6Capable = virQEMUCapsGet(priv->qemuCaps,
- QEMU_CAPS_IPV6_MIGRATION);
-
- if (listenAddress) {
- if (virSocketAddrNumericFamily(listenAddress) == AF_INET6) {
- if (!qemuIPv6Capable) {
- virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
- _("qemu isn't capable of IPv6"));
- goto cleanup;
- }
- if (!hostIPv6Capable) {
- virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
- _("host isn't capable of IPv6"));
- goto cleanup;
- }
- /* IPv6 address must be escaped in brackets on the cmd line */
- encloseAddress = true;
- } else {
- /* listenAddress is a hostname or IPv4 */
- }
- } else if (qemuIPv6Capable && hostIPv6Capable) {
- /* Listen on :: instead of 0.0.0.0 if QEMU understands it
- * and there is at least one IPv6 address configured
- */
- listenAddress = "::";
- encloseAddress = true;
- } else {
- listenAddress = "0.0.0.0";
- }
-
/* QEMU will be started with
* -incoming protocol:[<IPv6 addr>]:port,
* -incoming protocol:<IPv4 addr>:port, or
* -incoming protocol:<hostname>:port
*/
- if (encloseAddress)
+ if (virSocketAddrNumericFamily(listenAddress) == AF_INET6)
incFormat = "%s:[%s]:%d";
else
incFormat = "%s:%s:%d";
@@ -3540,6 +3500,43 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
goto stopjob;
stopProcess = true;
+ if (!tunnel) {
+ bool hostIPv6Capable = false;
+ bool qemuIPv6Capable = false;
+ struct addrinfo *info = NULL;
+ struct addrinfo hints = { .ai_flags = AI_ADDRCONFIG,
+ .ai_socktype = SOCK_STREAM };
+
+ if (getaddrinfo("::", NULL, &hints, &info) == 0) {
+ freeaddrinfo(info);
+ hostIPv6Capable = true;
+ }
+ qemuIPv6Capable = virQEMUCapsGet(priv->qemuCaps,
+ QEMU_CAPS_IPV6_MIGRATION);
+
+ if (listenAddress) {
+ if (virSocketAddrNumericFamily(listenAddress) == AF_INET6) {
+ if (!qemuIPv6Capable) {
+ virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+ _("qemu isn't capable of IPv6"));
+ goto stopjob;
+ }
+ if (!hostIPv6Capable) {
+ virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+ _("host isn't capable of IPv6"));
+ goto stopjob;
+ }
+ }
+ } else if (qemuIPv6Capable && hostIPv6Capable) {
+ /* Listen on :: instead of 0.0.0.0 if QEMU understands it
+ * and there is at least one IPv6 address configured
+ */
+ listenAddress = "::";
+ } else {
+ listenAddress = "0.0.0.0";
+ }
+ }
+
if (!(incoming = qemuMigrationPrepareIncoming(vm, tunnel, protocol,
listenAddress, port,
dataFD[0])))
--
2.4.3
8 years, 9 months
[libvirt] [PATCH] nestedhvm for libxl
by Alvin Starr
This patch adds a nestedhvm directive to the lxm features to allow libxl to create a nested HVM.
It also has mask_svm_npt to allow the created HVM to have the svm/npt bits masked so that it cannot in turn run up an nested hvm.
Alvin Starr (1):
add nested HVM to libxl
docs/schemas/domaincommon.rng | 10 ++++++++++
src/conf/domain_conf.c | 6 ++++++
src/conf/domain_conf.h | 2 ++
src/libxl/libxl_conf.c | 35 +++++++++++++++++++++++++++++++++++
4 files changed, 53 insertions(+)
--
2.4.3
8 years, 9 months
[libvirt] [PATCH 0/2] Couple of logging memleaks
by Michal Privoznik
I've found them by pure chance and they were easy to fix.
Michal Privoznik (2):
virLogHostnameString: Don't leak hostname
virLogVMessage: Don't leak rawinitmsg
src/util/virlog.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
--
2.4.10
8 years, 9 months
[libvirt] [PATCH v2 00/14] Use macros for more common virsh command options
by John Ferlan
v1: http://www.redhat.com/archives/libvir-list/2015-December/msg00731.html
Changes over v1:
1. Insert patch 1 to convert already pushed VSH_POOL into VIRSH_POOL
since that was the review comment from this patch series
2. Insert patch 2 to move the POOL_OPT_COMMON to virsh.h for later
patch reuse.
3. Use VIRSH_* instead of VSH_* for patches 1-8 (now 3-10)
4. Add usage of common domain for virsh-domain-monitor.c and
virsh-snapshot.c (patches 11-12)
5. Add common macros for "network" and "interface" (patches 13-14).
NOTE: I figure to let this perculate for a bit as I'll assume there
may be varying opinions on this... Also, the next couple of weeks
heavy on people perhaps paying not paying close attention to the list.
John Ferlan (14):
virsh: Covert VSH_POOL_ macro to VIRSH_POOL_
virsh: Move VIRSH_POOL_OPT_COMMON to virsh.h
virsh: Create macro for common "domain" option
virsh: Create macro for common "persistent" option
virsh: Create macro for common "config" option
virsh: Create macro for common "live" option
virsh: Create macro for common "current" option
virsh: Create macro for common "file" option
virsh: Create macros for common "pool" options
virsh: Create macros for common "vol" options
virsh: Have domain-monitor use common "domain" option
virsh: have snapshot use common "domain" option
virsh: Create macro for common "network" option
virsh: Create macro for common "interface" option
po/POTFILES.in | 1 +
tools/virsh-domain-monitor.c | 77 +---
tools/virsh-domain.c | 911 +++++++++----------------------------------
tools/virsh-interface.c | 37 +-
tools/virsh-network.c | 61 +--
tools/virsh-pool.c | 71 ++--
tools/virsh-snapshot.c | 60 +--
tools/virsh-volume.c | 148 ++-----
tools/virsh.h | 17 +
9 files changed, 334 insertions(+), 1049 deletions(-)
--
2.5.0
8 years, 9 months
[libvirt] [PATCH] Fix LSB requirements in service script and sync them
by Martin Kletzander
Commit b22344f3285187ee1768d6e031bc0ff20e32552d mistakenly reordered
Default-* lines. Thanks to that I noticed that we are very inconsistent
with our init scripts, so I took the liberty of synchronizing them,
updating them and making them all look shiny and new. So apart from
fixing the LSB requirements, I also fixed the ordering, specified
runlevels and fix the link to the reference specification.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
daemon/libvirtd.init.in | 11 ++++-------
src/locking/virtlockd.init.in | 12 ++++++++----
src/logging/virtlogd.init.in | 8 ++++----
tools/libvirt-guests.init.in | 9 ++++++---
4 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/daemon/libvirtd.init.in b/daemon/libvirtd.init.in
index 22006c448cdf..164732905d4b 100644
--- a/daemon/libvirtd.init.in
+++ b/daemon/libvirtd.init.in
@@ -1,19 +1,16 @@
#!/bin/sh
# the following is the LSB init header see
-# http://www.linux-foundation.org/spec//booksets/LSB-Core-generic/LSB-Core-...
+# http://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-g...
#
### BEGIN INIT INFO
# Provides: libvirtd
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
# Required-Start: $network messagebus virtlogd
-# Should-Start: $named
-# Should-Start: xend
-# Should-Start: avahi-daemon
-# Should-Start: virtlockd
# Required-Stop: $network messagebus
+# Should-Start: $named xend avahi-daemon virtlockd
# Should-Stop: $named
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 2 6
# Short-Description: daemon for libvirt virtualization API
# Description: This is a daemon for managing guest instances
# and libvirt virtual networks
diff --git a/src/locking/virtlockd.init.in b/src/locking/virtlockd.init.in
index 596bb6241485..0bf868ca7ff1 100644
--- a/src/locking/virtlockd.init.in
+++ b/src/locking/virtlockd.init.in
@@ -1,12 +1,16 @@
#!/bin/sh
# the following is the LSB init header see
-# http://www.linux-foundation.org/spec//booksets/LSB-Core-generic/LSB-Core-...
+# http://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-g...
#
### BEGIN INIT INFO
# Provides: virtlockd
-# Default-Start:
-# Default-Stop: 0 1 2 3 4 5 6
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+# Required-Start:
+# Required-Stop:
+# Should-Start: $network $remote_fs
+# Should-Stop: $network $remote_fs
# Short-Description: virtual machine lock manager
# Description: This is a daemon for managing locks
# on virtual machine disk images
@@ -16,7 +20,7 @@
#
# virtlockd: virtual machine lock manager
#
-# chkconfig: - 96 04
+# chkconfig: 345 96 04
# description: This is a daemon for managing locks \
# on virtual machine disk images
#
diff --git a/src/logging/virtlogd.init.in b/src/logging/virtlogd.init.in
index 89b243dc0522..6aa88150469f 100644
--- a/src/logging/virtlogd.init.in
+++ b/src/logging/virtlogd.init.in
@@ -1,16 +1,16 @@
#!/bin/sh
# the following is the LSB init header see
-# http://www.linux-foundation.org/spec//booksets/LSB-Core-generic/LSB-Core-...
+# http://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-g...
#
### BEGIN INIT INFO
# Provides: virtlogd
-# Default-Start: 3 5
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
# Required-Start:
# Required-Stop:
# Should-Start: $network $remote_fs
# Should-Stop: $network $remote_fs
-# Default-Stop: 0 1 2 4 6
# Short-Description: virtual machine log manager
# Description: This is a daemon for managing logs
# of virtual machine consoles
@@ -20,7 +20,7 @@
#
# virtlogd: virtual machine log manager
#
-# chkconfig: - 96 04
+# chkconfig: 345 96 04
# description: This is a daemon for managing logs \
# of virtual machine consoles
#
diff --git a/tools/libvirt-guests.init.in b/tools/libvirt-guests.init.in
index 5f9a60e81f05..7709df3b96a3 100644
--- a/tools/libvirt-guests.init.in
+++ b/tools/libvirt-guests.init.in
@@ -1,13 +1,16 @@
#!/bin/sh
-# the following is the LSB init header
+# the following is the LSB init header see
+# http://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-g...
#
### BEGIN INIT INFO
# Provides: libvirt-guests
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
# Required-Start: libvirtd
# Required-Stop: libvirtd
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
+# Should-Start:
+# Should-Stop:
# Short-Description: suspend/resume libvirt guests on shutdown/boot
# Description: This is a script for suspending active libvirt guests
# on shutdown and resuming them on next boot
--
2.7.0
8 years, 9 months
[libvirt] [PATCH] qemu: Don't bother user with libvirt-internal paths
by Martin Kletzander
If user defines a virtio channel with UNIX socket backend and doesn't
care about the path for the socket (e.g. qemu-agent channel), we still
generate it into the persistent XML. Moreover when then user renames
the domain, due to its persistent socket path saved into the per-domain
directory, it will not start. So let's forget about old generated paths
and also stop putting them into the persistent definition.
https://bugzilla.redhat.com/show_bug.cgi?id=1278068
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_command.c | 12 ++++++++++++
src/qemu/qemu_domain.c | 21 +++++++++++----------
.../qemuxml2argv-channel-virtio-unix.args | 5 ++++-
.../qemuxml2argv-channel-virtio-unix.xml | 4 ++++
4 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 66ca11152ad8..c5127cfa04f9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10510,6 +10510,18 @@ qemuBuildCommandLine(virConnectPtr conn,
goto error;
}
+ if (channel->source.type == VIR_DOMAIN_CHR_TYPE_UNIX &&
+ !channel->source.data.nix.path) {
+ if (virAsprintf(&channel->source.data.nix.path,
+ "%s/domain-%s/%s",
+ cfg->channelTargetDir, def->name,
+ channel->target.name ? channel->target.name
+ : "unknown.sock") < 0)
+ goto error;
+
+ channel->source.data.nix.listen = true;
+ }
+
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC) &&
channel->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
/* spicevmc was originally introduced via a -device
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index bb8d47f9293d..73fc79dab56b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1329,20 +1329,21 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
ARCH_IS_S390(def->os.arch))
dev->data.controller->model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
- /* auto generate unix socket path */
+ /* clear auto generated unix socket path */
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
dev->data.chr->source.type == VIR_DOMAIN_CHR_TYPE_UNIX &&
- !dev->data.chr->source.data.nix.path) {
- if (virAsprintf(&dev->data.chr->source.data.nix.path,
- "%s/domain-%s/%s",
- cfg->channelTargetDir, def->name,
- dev->data.chr->target.name ? dev->data.chr->target.name
- : "unknown.sock") < 0)
- goto cleanup;
-
- dev->data.chr->source.data.nix.listen = true;
+ dev->data.chr->source.data.nix.path &&
+ STRPREFIX(dev->data.chr->source.data.nix.path, cfg->channelTargetDir)) {
+ /*
+ * If the address is generated by us (starts with our
+ * channel dir), we should not keep it in the persistent
+ * XML. If libvirt is the one who generated it, users
+ * shouldn't care about that. If they do, they are
+ * supposed to set it themselves.
+ */
+ VIR_FREE(dev->data.chr->source.data.nix.path);
}
/* forbid capabilities mode hostdev in this kind of hypervisor */
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args
index 94375b85df69..6a0b1f373603 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args
@@ -33,4 +33,7 @@ nowait \
id=channel1 \
-chardev socket,id=charchannel2,path=/tmp/domain-QEMUGuest1/ble,server,nowait \
-device virtserialport,bus=virtio-serial0.0,nr=3,chardev=charchannel2,\
-id=channel2,name=ble
+id=channel2,name=ble \
+-chardev socket,id=charchannel3,path=/tmp/domain-QEMUGuest1/fdsa,server,nowait \
+-device virtserialport,bus=virtio-serial0.0,nr=4,chardev=charchannel3,\
+id=channel3,name=fdsa
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml
index 7fac943389bf..405dff8389bf 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml
@@ -32,6 +32,10 @@
<channel type='unix'>
<target type='virtio' name='ble'/>
</channel>
+ <channel type='unix'>
+ <source path='/tmp/domain-oldname/fdsa'/>
+ <target type='virtio' name='fdsa'/>
+ </channel>
<memballoon model='none'/>
</devices>
</domain>
--
2.7.0
8 years, 9 months
[libvirt] [PATCH] qemu: snapshot: Skip 'transaction' command when no disks are selected
by Peter Krempa
When doing a memory-only snapshot libvirt would still issue the
'transaction' command without any disk. Skip it if it isn't necessary.
---
src/qemu/qemu_driver.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1161aa0..39c2c05 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14331,6 +14331,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virJSONValuePtr actions = NULL;
+ bool do_transaction = false;
int ret = 0;
size_t i;
bool persist = false;
@@ -14379,9 +14380,11 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
reuse, asyncJob);
if (ret < 0)
break;
+
+ do_transaction = true;
}
if (actions) {
- if (ret == 0) {
+ if (ret == 0 && do_transaction) {
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
ret = qemuMonitorTransaction(priv->mon, actions);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
@@ -14390,6 +14393,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
/* failed to enter monitor, clean stuff up and quit */
ret = -1;
}
+ } else {
+ VIR_DEBUG("no disks to snapshot, skipping 'transaction' command");
}
virJSONValueFree(actions);
--
2.6.2
8 years, 10 months
[libvirt] [PATCH v2] fix LSB part of virtlogd runlevel script
by Olaf Hering
Currently pkg build of master branch fails:
[ 300s] + /usr/lib/rpm/brp-boot-scripts
[ 300s] E: File `virtlogd' is missing `Required-Start', please add even if empty!
[ 300s] W: File `virtlogd' is missing `Required-Stop', please add even if empty!
[ 300s] E: File `virtlogd' has empty `Default-Start', please specify default runlevel(s)!
[ 300s] ERROR: found one or more broken init or boot scripts, please fix them.
[ 300s] For more information about LSB headers please read the manual
[ 300s] page of of insserv by executing the command `man 8 insserv'.
[ 300s] If you don't understand this, mailto=werner(a)suse.de
[ 300s] error: Bad exit status from /var/tmp/rpm-tmp.44965 (%install)
Add the required tags, fix the existing tags.
Use soft dependency "Should-Start" because virtlogd may work without network.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
v2: fix colon in Should-stop
src/logging/virtlogd.init.in | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/logging/virtlogd.init.in b/src/logging/virtlogd.init.in
index 1408236..dadc343 100644
--- a/src/logging/virtlogd.init.in
+++ b/src/logging/virtlogd.init.in
@@ -5,8 +5,12 @@
#
### BEGIN INIT INFO
# Provides: virtlogd
-# Default-Start:
-# Default-Stop: 0 1 2 3 4 5 6
+# Default-Start: 3 5
+# Required-Start:
+# Required-Stop:
+# Should-Start: $network $remote_fs
+# Should-Stop: $network $remote_fs
+# Default-Stop: 0 1 2 4 6
# Short-Description: virtual machine log manager
# Description: This is a daemon for managing logs
# of virtual machine consoles
8 years, 10 months
[libvirt] <interface type='hostdev'>vf configuration cleanup when VM is delete
by Moshe Levi
Hi,
I have a setup with libvirt 1.3.0 and OpenStack trunk.
Before launched the VM ip link command show the following VF mac/vlan configuration [1]
When I launch a VM with <interface type='hostdev'> via openstack api (OpenStack direct port)
I can see that the VF get the mac/vlan according to libvrit xml [2] and ip link command [3], but when I delete the VM the mac/vlan config are still shown as in [3] and not restored to [1]
Shouldn't libvirt restore the mac/vlan to [1].
The same problem exists when using <interface type='direct'> (OpenStack macvtap port) but just for the MAC configuration of the VF.
[1] - 24: enp3s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ovs-system state UP mode DEFAULT group default qlen 1000
link/ether e4:1d:2d:a5:f1:22 brd ff:ff:ff:ff:ff:ff
vf 0 MAC 00:00:00:00:00:00, spoof checking off, link-state auto
vf 1 MAC 00:00:00:00:00:00, spoof checking off, link-state auto
vf 2 MAC 00:00:00:00:00:00, spoof checking off, link-state auto
vf 3 MAC 00:00:00:00:00:00, spoof checking off, link-state auto
[2] - <interface type='hostdev' managed='yes'>
<mac address=' fa:16:3e:11:af:fe '/>
<driver name='kvm'/>
<source>
<address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x7'/>
</source>
<vlan>
<tag id='190'/>
</vlan>
<alias name='hostdev0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
[3] 24: enp3s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ovs-system state UP mode DEFAULT group default qlen 1000
link/ether e4:1d:2d:a5:f1:22 brd ff:ff:ff:ff:ff:ff
vf 0 MAC 00:00:00:00:00:00, spoof checking off, link-state auto
vf 1 MAC 00:00:00:00:00:00, spoof checking off, link-state auto
vf 2 MAC 00:00:00:00:00:00, spoof checking off, link-state auto
vf 3 MAC fa:16:3e:11:af:fe, vlan 190, spoof checking off, link-state enable
8 years, 10 months
[libvirt] [PATCH] qemu: save config after pivot only if domain is persistent
by Michael Chapman
When pivoting after a completed block job, only save the domain's
persistent configuration if the domain is actually marked persistent.
This commit also refactors the logic surrounding the copying of the new
disk definition into vm->newDef to avoid a NULL pointer dereference if
virStorageSourceCopy were to fail to allocate memory.
Signed-off-by: Michael Chapman <mike(a)very.puzzling.org>
---
src/qemu/qemu_blockjob.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 1d5b7ce..ae936a2 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -116,26 +116,20 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
switch ((virConnectDomainEventBlockJobStatus) status) {
case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
if (disk->mirrorState == VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT) {
- if (vm->newDef) {
- virStorageSourcePtr copy = NULL;
-
- if ((persistDisk = virDomainDiskByName(vm->newDef,
- disk->dst, false))) {
- copy = virStorageSourceCopy(disk->mirror, false);
- if (virStorageSourceInitChainElement(copy,
- persistDisk->src,
- true) < 0) {
- VIR_WARN("Unable to update persistent definition "
- "on vm %s after block job",
- vm->def->name);
- virStorageSourceFree(copy);
- copy = NULL;
- persistDisk = NULL;
- }
- }
- if (copy) {
+ if (vm->newDef &&
+ (persistDisk = virDomainDiskByName(vm->newDef, disk->dst, false))) {
+ virStorageSourcePtr copy = virStorageSourceCopy(disk->mirror, false);
+ if (copy && virStorageSourceInitChainElement(copy,
+ persistDisk->src,
+ true) == 0) {
virStorageSourceFree(persistDisk->src);
persistDisk->src = copy;
+ } else {
+ VIR_WARN("Unable to update persistent definition "
+ "on vm %s after block job",
+ vm->def->name);
+ virStorageSourceFree(copy);
+ persistDisk = NULL;
}
}
@@ -188,8 +182,8 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
VIR_WARN("Unable to save status on vm %s after block job",
vm->def->name);
- if (persistDisk && virDomainSaveConfig(cfg->configDir,
- vm->newDef) < 0)
+ if (vm->persistent && persistDisk &&
+ virDomainSaveConfig(cfg->configDir, vm->newDef) < 0)
VIR_WARN("Unable to update persistent definition on vm %s "
"after block job", vm->def->name);
}
--
2.4.3
8 years, 10 months