[libvirt] [PATCH 0/3] qemu: Fix checks when changing disk media

Few fields were missing and few fields can be actually changed. The last two patches actually fix https://bugzilla.redhat.com/show_bug.cgi?id=1326660 since we reported incorrect error message. Peter Krempa (3): qemu: domain: Fix error message in qemuDomainDiskChangeSupported qemu: domain: Check few more fields for when changing disk source qemu: hotplug: Allow update of disk default snapshot location src/qemu/qemu_domain.c | 10 ++++++++-- src/qemu/qemu_driver.c | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) -- 2.8.1

disk->dst represents the <target> element in the XML. --- src/qemu/qemu_domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6262bfe..8132ff6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3828,7 +3828,7 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk, if (STRNEQ(disk->dst, orig_disk->dst)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("cannot modify field '%s' of the disk"), - "bus"); + "target"); return false; } CHECK_EQ(tray_status, "tray", true); -- 2.8.1

Both disk->src->shared and disk->src->readonly can't be modified when changing disk source for floppy and cdrom drives since both arguments are passed as arguments of the disk rather than the image in qemu. Historically these fields have only two possible values since they are represented as XML thus we need to ignore if user did not provide them and thus we are treating them as false. --- src/qemu/qemu_domain.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8132ff6..f6e68ea 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3940,6 +3940,12 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk, return false; } + /* checks for fields stored in disk->src */ + /* unfortunately 'readonly' and 'shared' can't be converted to tristate + * values thus we need to ignore the check if the new value is 'false' */ + CHECK_EQ(src->readonly, "readonly", true); + CHECK_EQ(src->shared, "shared", true); + #undef CHECK_EQ return true; -- 2.8.1

Since the field is internal to libvirt we can allow the users to modify it. --- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_driver.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f6e68ea..e6cd775 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3923,7 +3923,7 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk, CHECK_EQ(ioeventfd, "ioeventfd", true); CHECK_EQ(event_idx, "event_idx", true); CHECK_EQ(copy_on_read, "copy_on_read", true); - CHECK_EQ(snapshot, "snapshot", true); + /* "snapshot" is a libvirt internal field and thus can be changed */ /* startupPolicy is allowed to be updated. Therefore not checked here. */ CHECK_EQ(transient, "transient", true); CHECK_EQ(info.bootIndex, "boot order", true); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e5badf6..351f400 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7682,6 +7682,7 @@ qemuDomainChangeDiskLive(virConnectPtr conn, virDomainDiskDefPtr disk = dev->data.disk; virDomainDiskDefPtr orig_disk = NULL; int startupPolicy; + int snapshot; int ret = -1; if (virStorageTranslateDiskSourcePool(conn, disk) < 0) @@ -7700,6 +7701,7 @@ qemuDomainChangeDiskLive(virConnectPtr conn, } startupPolicy = orig_disk->startupPolicy; + snapshot = orig_disk->snapshot; switch ((virDomainDiskDevice) disk->device) { case VIR_DOMAIN_DISK_DEVICE_CDROM: @@ -7708,6 +7710,7 @@ qemuDomainChangeDiskLive(virConnectPtr conn, goto cleanup; orig_disk->startupPolicy = dev->data.disk->startupPolicy; + orig_disk->snapshot = dev->data.disk->snapshot; if (qemuDomainDiskSourceDiffers(conn, disk, orig_disk)) { /* Add the new disk src into shared disk hash table */ @@ -7742,6 +7745,7 @@ qemuDomainChangeDiskLive(virConnectPtr conn, return ret; rollback: + orig_disk->snapshot = snapshot; orig_disk->startupPolicy = startupPolicy; goto cleanup; } -- 2.8.1

On Thu, Apr 28, 2016 at 18:08:56 +0200, Peter Krempa wrote:
Few fields were missing and few fields can be actually changed.
The last two patches actually fix https://bugzilla.redhat.com/show_bug.cgi?id=1326660 since we reported incorrect
Oops, incorrect BZ. The correct one is: https://bugzilla.redhat.com/show_bug.cgi?id=1328301

On 28.04.2016 18:08, Peter Krempa wrote:
Few fields were missing and few fields can be actually changed.
The last two patches actually fix https://bugzilla.redhat.com/show_bug.cgi?id=1326660 since we reported incorrect error message.
Peter Krempa (3): qemu: domain: Fix error message in qemuDomainDiskChangeSupported qemu: domain: Check few more fields for when changing disk source qemu: hotplug: Allow update of disk default snapshot location
src/qemu/qemu_domain.c | 10 ++++++++-- src/qemu/qemu_driver.c | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-)
ACK to all of them and safe for freeze. Michal
participants (2)
-
Michal Privoznik
-
Peter Krempa