Re: [PATCH v1 31/31] qemu_hotplug: Prepare NVMe disks on hotplug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 11, 2019 at 17:54:18 +0200, Michal Privoznik wrote:
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/qemu/qemu_hotplug.c | 65 +++++++++++++++++++++++++++++++++++++----
>  1 file changed, 60 insertions(+), 5 deletions(-)
> 
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 3c6c0da3a0..6dbff23aa0 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -605,6 +605,54 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
>  }
>  
>  
> +static int
> +qemuDomainStorageSourcePrepareDisk(virQEMUDriverPtr driver,
> +                                   virDomainObjPtr vm,
> +                                   virDomainDiskDefPtr disk,
> +                                   bool teardown)
> +{
> +    int rc;
> +    bool adjustMemlock = false;
> +    bool reattach = false;
> +
> +    if (!virDomainDefHasNVMeDisk(vm->def) &&
> +        !virStorageSourceChainHasNVMe(disk->src))
> +        return 0;
> +
> +    if (teardown) {
> +        adjustMemlock = true;
> +        reattach = true;
> +        goto rollback;
> +    }
> +
> +    /* Tentatively add disk to domain def so that memlock limit can be computed. */
> +    vm->def->disks[vm->def->ndisks++] = disk;
> +    rc = qemuDomainAdjustMaxMemLock(vm);
> +    vm->def->disks[--vm->def->ndisks] = NULL;
> +
> +    if (rc < 0)
> +        return -1;
> +
> +    adjustMemlock = true;

What's the point of this ...

> +
> +    if (qemuHostdevPrepareNVMeDevices(driver, vm->def->name, &disk, 1) < 0)
> +        return -1;

... if this just exits the function?

> +
> +    reattach = true;
> +
> +    return 0;
> +
> + rollback:
> +    if (reattach)
> +        qemuHostdevReAttachNVMeDevices(driver, vm->def->name, &disk, 1);
> +
> +    if (adjustMemlock)
> +        qemuDomainAdjustMaxMemLock(vm);
> +
> +    return 0;
> +}
> +
> +
>  /**
>   * qemuDomainAttachDiskGeneric:
>   *

[...]

> @@ -683,8 +734,10 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
>      ret = 0;
>  
>   cleanup:
> -    if (ret < 0)
> +    if (ret < 0) {
>          ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src));
> +        qemuDomainStorageSourcePrepareDisk(driver, vm, disk, true);
> +    }
>      qemuDomainSecretDiskDestroy(disk);
>      VIR_FREE(devstr);
>      return ret;
> @@ -4267,6 +4320,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
>      dev.data.disk = disk;
>      ignore_value(qemuRemoveSharedDevice(driver, &dev, vm->def->name));
>  
> +    qemuDomainStorageSourcePrepareDisk(driver, vm, disk, true);
> +

I'd prefer if you could base this on top of the new disk source tracking
for new blockjobs I've done for -blockdev support:

git fetch https://github.com/pipo/libvirt.git job-tracking-send

That code tentatively moves this out if the disk backend is still
required while the frontend was unplugged.

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux