Re: [PATCHv2 40/62] qemu: process: Add lookup via QOM id to qemuProcessFindDomainDiskByAlias

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

 



On Mon, Aug 13, 2018 at 18:00:14 +0200, Peter Krempa wrote:
> Allow looking up also via QOM id and rename the function accordingly.
> Also add documentation of the specifics.
> 
> Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
> ---
>  src/qemu/qemu_driver.c  |  2 +-
>  src/qemu/qemu_process.c | 42 +++++++++++++++++++++++++++++++-----------
>  src/qemu/qemu_process.h |  5 +++--
>  3 files changed, 35 insertions(+), 14 deletions(-)

[...]

> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index 3495733041..b713afa3a2 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -350,28 +350,48 @@ qemuProcessHandleMonitorError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,

[...]

>  virDomainDiskDefPtr
> -qemuProcessFindDomainDiskByAlias(virDomainObjPtr vm,
> -                                 const char *alias)
> +qemuProcessFindDomainDiskByAliasOrQOM(virDomainObjPtr vm,
> +                                      const char *alias,
> +                                      const char *qomid)
>  {
>      size_t i;
> 
> -    alias = qemuAliasDiskDriveSkipPrefix(alias);
> +    if (*alias == '\0')
> +        alias = NULL;

Some of the callers already do this and thus pass NULL here, so this
function would crash in that case. Consider this squashed in:

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 15e7c951b6..f6f494cad5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -370,7 +370,8 @@ qemuProcessFindDomainDiskByAliasOrQOM(virDomainObjPtr vm,
 {
     size_t i;

-    if (*alias == '\0')
+    if (alias &&
+        *alias == '\0')
         alias = NULL;

     if (alias)

> +
> +    if (alias)
> +        alias = qemuAliasDiskDriveSkipPrefix(alias);
> 

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