[libvirt] [PATCHv3 09/12] qemu: add support for memory devices

John Ferlan jferlan at redhat.com
Thu Mar 19 22:38:37 UTC 2015



On 03/17/2015 10:19 AM, Peter Krempa wrote:
> Add support to start qemu instance with 'pc-dimm' device. Thanks to the
> refactors we are able to reuse the existing function to determine the
> parameters.
> ---
> 
> Notes:
>     Version 2:
>     - dropped the ACPI naming
> 
>  src/qemu/qemu_command.c                            | 130 ++++++++++++++++++++-
>  src/qemu/qemu_domain.c                             |  26 ++++-
>  src/qemu/qemu_domain.h                             |   1 +
>  .../qemuxml2argv-memory-hotplug-dimm.args          |  11 ++
>  tests/qemuxml2argvtest.c                           |   2 +
>  tests/qemuxml2xmltest.c                            |   1 +
>  6 files changed, 167 insertions(+), 4 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.args
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index ef8feeb..2d85567 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -1222,6 +1222,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
>          if (virAsprintf(&def->tpm->info.alias, "tpm%d", 0) < 0)
>              return -1;
>      }
> +    for (i = 0; i < def->nmems; i++) {
> +        if (virAsprintf(&def->mems[i]->info.alias, "dimm%zu", i) < 0)
> +            return -1;
> +    }
> 
>      return 0;
>  }
> @@ -4612,8 +4616,7 @@ qemuBuildMemoryBackendStr(unsigned long long size,
>      virDomainHugePagePtr hugepage = NULL;
>      virDomainNumatuneMemMode mode;
>      const long system_page_size = virGetSystemPageSizeKB();
> -    virNumaMemAccess memAccess = virDomainNumaGetNodeMemoryAccessMode(def->numa, guestNode);
> -
> +    virNumaMemAccess memAccess = VIR_NUMA_MEM_ACCESS_DEFAULT;
>      size_t i;
>      char *mem_path = NULL;
>      virBitmapPtr nodemask = NULL;
> @@ -4626,6 +4629,16 @@ qemuBuildMemoryBackendStr(unsigned long long size,
>      if (!(props = virJSONValueNewObject()))
>          return -1;
> 
> +    /* memory devices could provide a invalid guest node */
> +    if (guestNode >= virDomainNumaGetNodeCount(def->numa)) {
> +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                       _("can't add memory backend for guest node '%d' as "
> +                         "the guest has only '%zu' NUMA nodes configured"),
> +                       guestNode, virDomainNumaGetNodeCount(def->numa));

Coverity points out that 'props' is being leaked here.  So probably
should go to cleanup or move this entire hunk above the props = line.

In my test I just moved these lines above the props fetch and Coverity
was happy

John

> +        return -1;
> +    }
> +
> +    memAccess = virDomainNumaGetNodeMemoryAccessMode(def->numa, guestNode);
>      mode = virDomainNumatuneGetMode(def->numa, guestNode);
> 
>      if (pagesize == 0 || pagesize != system_page_size) {
> @@ -4823,6 +4836,95 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
>  }
> 
> 




More information about the libvir-list mailing list