[libvirt] [PATCH v2] vz: handle sourceless cdroms

Maxim Nestratov mnestratov at virtuozzo.com
Tue Apr 19 16:56:24 UTC 2016


14.04.2016 18:00, Nikolay Shirokovskiy пишет:

> From: Mikhail Feoktistov <mfeoktistov at virtuozzo.com>
>
> libvirt handles empty source as NULL, while vz sdk as
> "" thus we need a bit of conversion.
>
> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
> ---
>   src/vz/vz_sdk.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> changes from v1:
> ================
> 1. simplify empty string check in prlsdkGetDiskInfo
> 2. call setting "" explicitly in prlsdkAddDisk.
>
> point 2 is the actual reason for releasing new version. I need
> this semantics on my future work of updating disks.
>
> diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
> index 2e9544b..9b783af 100644
> --- a/src/vz/vz_sdk.c
> +++ b/src/vz/vz_sdk.c
> @@ -565,7 +565,7 @@ prlsdkGetDiskInfo(vzDriverPtr driver,
>       if (!(buf = prlsdkGetStringParamVar(PrlVmDev_GetFriendlyName, prldisk)))
>           goto cleanup;
>   
> -    if (virDomainDiskSetSource(disk, buf) < 0)
> +    if (*buf != '\0' && virDomainDiskSetSource(disk, buf) < 0)
>           goto cleanup;
>   
>       if (prlsdkGetDiskId(prldisk, isCt, &disk->bus, &disk->dst) < 0)
> @@ -3183,6 +3183,7 @@ static int prlsdkAddDisk(vzDriverPtr driver,
>       PRL_DEVICE_TYPE devType;
>       PRL_CLUSTERED_DEVICE_SUBTYPE scsiModel;
>       char *dst = NULL;
> +    const char *path = disk->src->path ? : "";
>   
>       if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK)
>           devType = PDE_HARD_DISK;
> @@ -3206,10 +3207,10 @@ static int prlsdkAddDisk(vzDriverPtr driver,
>       pret = PrlVmDev_SetEmulatedType(sdkdisk, emutype);
>       prlsdkCheckRetGoto(pret, cleanup);
>   
> -    pret = PrlVmDev_SetSysName(sdkdisk, disk->src->path);
> +    pret = PrlVmDev_SetSysName(sdkdisk, path);
>       prlsdkCheckRetGoto(pret, cleanup);
>   
> -    pret = PrlVmDev_SetFriendlyName(sdkdisk, disk->src->path);
> +    pret = PrlVmDev_SetFriendlyName(sdkdisk, path);
>       prlsdkCheckRetGoto(pret, cleanup);
>   
>       drive = &disk->info.addr.drive;

ACK.
Pushed, thanks.

Maxim




More information about the libvir-list mailing list