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