[libvirt] [PATCH 0/2] vz: add serial number to disk devices

Only the first patch is really on the subject. The second one is bugfix that is included mainly because it touches the same place (and nice to have to test first patch too...) Nikolay Shirokovskiy (2): vz: add serial number to disk devices vz: set something in disk driver name src/vz/vz_sdk.c | 16 ++++++++++++++++ src/vz/vz_utils.c | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) -- 1.8.3.1

vz sdk supports setting serial number only for disk devices. Getting serial upon cdrom(for example) is error however setting is just ignored. Let's check for disk device explicitly for clarity in both cases. Setting serial number for other devices is ignored with an info note just as before. We need usual conversion from "" to NULL in direction vz sdk -> libvirt, because "" is not valid for libvirt and "" means unspecifiend in vz sdk which is NULL for libvirt. --- src/vz/vz_sdk.c | 13 +++++++++++++ src/vz/vz_utils.c | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index f2a5c96..a38f2af 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -639,6 +639,14 @@ prlsdkGetDiskInfo(vzDriverPtr driver, disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE; + if (!isCdrom) { + if (!(disk->serial = prlsdkGetStringParamVar(PrlVmDevHd_GetSerialNumber, prldisk))) + goto cleanup; + + if (*disk->serial == '\0') + VIR_FREE(disk->serial); + } + ret = 0; cleanup: @@ -3492,6 +3500,11 @@ static int prlsdkConfigureDisk(vzDriverPtr driver, pret = PrlVmDev_SetStackIndex(sdkdisk, idx); prlsdkCheckRetGoto(pret, cleanup); + if (devType == PDE_HARD_DISK) { + pret = PrlVmDevHd_SetSerialNumber(sdkdisk, disk->serial); + prlsdkCheckRetGoto(pret, cleanup); + } + return 0; cleanup: PrlHandle_Free(sdkdisk); diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c index eaf09f2..81429d2 100644 --- a/src/vz/vz_utils.c +++ b/src/vz/vz_utils.c @@ -323,9 +323,9 @@ vzCheckDiskUnsupportedParams(virDomainDiskDefPtr disk) return -1; } - if (disk->serial) { - VIR_INFO("%s", _("Setting disk serial number is not " - "supported by vz driver.")); + if (disk->serial && disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) { + VIR_INFO("%s", _("Setting disk serial number is " + "supported only for disk devices.")); } if (disk->wwn) { -- 1.8.3.1

22-Sep-16 17:55, Nikolay Shirokovskiy пишет:
vz sdk supports setting serial number only for disk devices. Getting serial upon cdrom(for example) is error however setting is just ignored. Let's check for disk device explicitly for clarity in both cases.
Setting serial number for other devices is ignored with an info note just as before.
We need usual conversion from "" to NULL in direction vz sdk -> libvirt, because "" is not valid for libvirt and "" means unspecifiend in vz sdk which is NULL for libvirt. --- src/vz/vz_sdk.c | 13 +++++++++++++ src/vz/vz_utils.c | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-)
Hmm. I missed this series and sent mine on the matter yesterday. I see that your patch has some useful changes regarding CDROM absent in my patch. So I'll merge these two and resend a new version shortly. Maxim
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index f2a5c96..a38f2af 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -639,6 +639,14 @@ prlsdkGetDiskInfo(vzDriverPtr driver,
disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE;
+ if (!isCdrom) { + if (!(disk->serial = prlsdkGetStringParamVar(PrlVmDevHd_GetSerialNumber, prldisk))) + goto cleanup; + + if (*disk->serial == '\0') + VIR_FREE(disk->serial); + } + ret = 0;
cleanup: @@ -3492,6 +3500,11 @@ static int prlsdkConfigureDisk(vzDriverPtr driver, pret = PrlVmDev_SetStackIndex(sdkdisk, idx); prlsdkCheckRetGoto(pret, cleanup);
+ if (devType == PDE_HARD_DISK) { + pret = PrlVmDevHd_SetSerialNumber(sdkdisk, disk->serial); + prlsdkCheckRetGoto(pret, cleanup); + } + return 0; cleanup: PrlHandle_Free(sdkdisk); diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c index eaf09f2..81429d2 100644 --- a/src/vz/vz_utils.c +++ b/src/vz/vz_utils.c @@ -323,9 +323,9 @@ vzCheckDiskUnsupportedParams(virDomainDiskDefPtr disk) return -1; }
- if (disk->serial) { - VIR_INFO("%s", _("Setting disk serial number is not " - "supported by vz driver.")); + if (disk->serial && disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) { + VIR_INFO("%s", _("Setting disk serial number is " + "supported only for disk devices.")); }
if (disk->wwn) {

Absent driver name attribute is invalid xml. Which in turn makes unusable 'virsh edit' for example. The value does not make much sense and ignored on input so nobody will hurt. --- src/vz/vz_sdk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index a38f2af..0af450b 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -647,6 +647,9 @@ prlsdkGetDiskInfo(vzDriverPtr driver, VIR_FREE(disk->serial); } + if (virDomainDiskSetDriver(disk, "vz") < 0) + goto cleanup; + ret = 0; cleanup: -- 1.8.3.1

22-Sep-16 17:55, Nikolay Shirokovskiy пишет:
Absent driver name attribute is invalid xml. Which in turn makes unusable 'virsh edit' for example. The value does not make much sense and ignored on input so nobody will hurt. --- src/vz/vz_sdk.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index a38f2af..0af450b 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -647,6 +647,9 @@ prlsdkGetDiskInfo(vzDriverPtr driver, VIR_FREE(disk->serial); }
+ if (virDomainDiskSetDriver(disk, "vz") < 0) + goto cleanup; + ret = 0;
cleanup:
ACK

22-Sep-16 17:55, Nikolay Shirokovskiy пишет:
Only the first patch is really on the subject. The second one is bugfix that is included mainly because it touches the same place (and nice to have to test first patch too...)
Nikolay Shirokovskiy (2): vz: add serial number to disk devices vz: set something in disk driver name
src/vz/vz_sdk.c | 16 ++++++++++++++++ src/vz/vz_utils.c | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-)
After offline discussion we decided to stick to this patch series. ACKed and pushed now. Maxim
participants (2)
-
Maxim Nestratov
-
Nikolay Shirokovskiy