[libvirt] [PATCHv2 08/62] qemu: hotplug: consolidate media change code paths

Ján Tomko jtomko at redhat.com
Tue Aug 14 15:20:23 UTC 2018


On Mon, Aug 13, 2018 at 05:59:42PM +0200, Peter Krempa wrote:
>Use qemuDomainAttachDeviceDiskLive to change the media in
>qemuDomainChangeDiskLive as the former function already does all the
>necessary steps to prepare the new medium.
>
>This also allows us to turn qemuDomainChangeEjectableMedia static.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/qemu/qemu_driver.c  | 18 ++----------------
> src/qemu/qemu_hotplug.c | 18 +++++++++++++++---
> src/qemu/qemu_hotplug.h |  9 ++-------
> tests/qemuhotplugtest.c |  2 +-
> 4 files changed, 20 insertions(+), 27 deletions(-)
>
>@@ -7884,16 +7878,8 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm,
>             goto cleanup;
>         }
>
>-        /* Add the new disk src into shared disk hash table */
>-        if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
>-            goto cleanup;
>-
>-        if (qemuDomainChangeEjectableMedia(driver, vm, orig_disk,
>-                                           dev->data.disk->src, force) < 0) {
>-            ignore_value(qemuRemoveSharedDisk(driver, dev->data.disk,
>-                                              vm->def->name));
>+        if (qemuDomainAttachDeviceDiskLive(driver, vm, dev, force) < 0)
>             goto cleanup;
>-        }
>
>         dev->data.disk->src = NULL;

This assignment is now redundant - if qemuDomainAttachDeviceDiskLive
returns 0, the pointer is already cleared.

>     }

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180814/d2151620/attachment-0001.sig>


More information about the libvir-list mailing list