Re: [PATCH v3 17/17] qemu: Namespaces for NVDIMM

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

 




On 03/09/2017 11:06 AM, Michal Privoznik wrote:
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/qemu/qemu_domain.c  | 76 +++++++++++++++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_domain.h  |  8 ++++++
>  src/qemu/qemu_hotplug.c | 11 +++++++
>  3 files changed, 95 insertions(+)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 495242981..552523617 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -7526,6 +7526,37 @@ qemuDomainSetupAllHostdevs(virQEMUDriverConfigPtr cfg,
>  }
>  
>  
> +static int
> +qemuDomainSetupMemory(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
> +                      virDomainMemoryDefPtr mem,
> +                      const char *devPath)
> +{
> +    if (mem->model != VIR_DOMAIN_MEMORY_MODEL_NVDIMM)
> +        return 0;
> +
> +    return qemuDomainCreateDevice(mem->nvdimmPath, devPath, false);
> +}
> +
> +
> +static int
> +qemuDomainSetupAllMemories(virQEMUDriverConfigPtr cfg,
> +                           virDomainObjPtr vm,
> +                           const char *devPath)
> +{
> +    size_t i;
> +
> +    VIR_DEBUG("Setting up memories");
> +    for (i = 0; i < vm->def->nmems; i++) {
> +        if (qemuDomainSetupMemory(cfg,
> +                                  vm->def->mems[i],
> +                                  devPath) < 0)
> +            return -1;
> +    }
> +    VIR_DEBUG("Setup all memories");
> +    return 0;
> +}
> +
> +
>  static int
>  qemuDomainSetupChardev(virDomainDefPtr def ATTRIBUTE_UNUSED,
>                         virDomainChrDefPtr dev,
> @@ -7770,6 +7801,9 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
>      if (qemuDomainSetupAllHostdevs(cfg, vm, devPath) < 0)
>          goto cleanup;
>  
> +    if (qemuDomainSetupAllMemories(cfg, vm, devPath) < 0)
> +        goto cleanup;
> +
>      if (qemuDomainSetupAllChardevs(cfg, vm, devPath) < 0)
>          goto cleanup;
>  
> @@ -8228,6 +8262,48 @@ qemuDomainNamespaceTeardownHostdev(virQEMUDriverPtr driver,
>  }
>  
>  
> +int
> +qemuDomainNamespaceSetupMemory(virQEMUDriverPtr driver,
> +                               virDomainObjPtr vm,
> +                               virDomainMemoryDefPtr mem)
> +{
> +    int ret = -1;
> +
> +    if (mem->model != VIR_DOMAIN_MEMORY_MODEL_NVDIMM)
> +        return 0;
> +
> +    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
> +        return 0;
> +
> +    if (qemuDomainAttachDeviceMknod(driver, vm, mem->nvdimmPath) < 0)
> +        goto cleanup;
> +    ret = 0;
> + cleanup:
> +    return ret;
> +}
> +
> +
> +int
> +qemuDomainNamespaceTeardownMemory(virQEMUDriverPtr driver,
> +                                  virDomainObjPtr vm,
> +                                  virDomainMemoryDefPtr mem)
> +{
> +    int ret = -1;
> +
> +    if (mem->model != VIR_DOMAIN_MEMORY_MODEL_NVDIMM)
> +        return 0;
> +
> +    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
> +        return 0;
> +
> +    if (qemuDomainDetachDeviceUnlink(driver, vm, mem->nvdimmPath) < 0)
> +        goto cleanup;
> +    ret = 0;
> + cleanup:
> +    return ret;
> +}
> +
> +
>  int
>  qemuDomainNamespaceSetupChardev(virQEMUDriverPtr driver,
>                                  virDomainObjPtr vm,
> diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
> index 7fa717390..f5b8d3fe7 100644
> --- a/src/qemu/qemu_domain.h
> +++ b/src/qemu/qemu_domain.h
> @@ -834,6 +834,14 @@ int qemuDomainNamespaceTeardownHostdev(virQEMUDriverPtr driver,
>                                         virDomainObjPtr vm,
>                                         virDomainHostdevDefPtr hostdev);
>  
> +int qemuDomainNamespaceSetupMemory(virQEMUDriverPtr driver,
> +                                   virDomainObjPtr vm,
> +                                   virDomainMemoryDefPtr memory);
> +
> +int qemuDomainNamespaceTeardownMemory(virQEMUDriverPtr driver,
> +                                      virDomainObjPtr vm,
> +                                      virDomainMemoryDefPtr memory);
> +
>  int qemuDomainNamespaceSetupChardev(virQEMUDriverPtr driver,
>                                      virDomainObjPtr vm,
>                                      virDomainChrDefPtr chr);
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 829b40258..392b2fd02 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -2217,6 +2217,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
>      bool objAdded = false;
>      bool teardownlabel = false;
>      bool teardowncgroup = false;
> +    bool teardowndevice = false;
>      virJSONValuePtr props = NULL;
>      virObjectEventPtr event;
>      int id;
> @@ -2246,6 +2247,10 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
>                                    priv->qemuCaps, vm->def, mem, NULL, true) < 0)
>          goto cleanup;
>  
> +    if (qemuDomainNamespaceSetupMemory(driver, vm, mem) < 0)
> +        goto removedef;

goto cleanup;

or whatever label was created from patch15

The virDomainMemoryInsert has not occurred yet.


> +    teardowndevice = true;
> +
>      if (qemuSetupMemoryDevicesCgroup(vm, mem) < 0)
>          goto cleanup;
>      teardowncgroup = true;
> @@ -2303,6 +2308,9 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
>              VIR_WARN("Unable to remove memory device cgroup ACL on hotplug fail");
>          if (teardownlabel && qemuSecurityRestoreMemoryLabel(driver, vm, mem) < 0)
>              VIR_WARN("Unable to restore security label on memdev");
> +        if (teardowndevice &&
> +            qemuDomainNamespaceTeardownMemory(driver, vm, mem) <  0)
> +            VIR_WARN("Unable to remove memory device from /dev");

Again here you could have an ordering problem... If setup was A, B, C,
then shouldn't teardown be C, B, A?

ACK with adjustments already mentioned from patch15/16

John
>      }
>  
>      virObjectUnref(cfg);
> @@ -3771,6 +3779,9 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
>      if (qemuTeardownMemoryDevicesCgroup(vm, mem) < 0)
>          VIR_WARN("Unable to remove memory device cgroup ACL");
>  
> +    if (qemuDomainNamespaceTeardownMemory(driver, vm, mem) <  0)
> +        VIR_WARN("Unable to remove memory device from /dev");
> +
>      virDomainMemoryDefFree(mem);
>  
>      /* fix the balloon size */
> 

--
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