[libvirt] [PATCH] xl: don't output (null) target in domxml-to-native

When converting a domain xml containing a CDROM device without any attached source, don't add a target=(null) to the libxl config disk definition: xen doesn't like it at all and would fail to start the domain. --- src/xenconfig/xen_xl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index a06983e..db8cbf1 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -1068,7 +1068,7 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk) /* devtype */ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) - virBufferAddLit(&buf, "devtype=cdrom,"); + virBufferAddLit(&buf, "devtype=cdrom"); /* * target @@ -1081,7 +1081,9 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk) if (xenFormatXLDiskSrc(disk->src, &target) < 0) goto cleanup; - virBufferAsprintf(&buf, "target=%s", target); + if (target) { + virBufferAsprintf(&buf, ",target=%s", target); + } if (virBufferCheckError(&buf) < 0) goto cleanup; -- 2.10.1

On Wed, Oct 19, 2016 at 12:10:00 +0200, Cédric Bosdonnat wrote:
When converting a domain xml containing a CDROM device without any attached source, don't add a target=(null) to the libxl config disk definition: xen doesn't like it at all and would fail to start the domain. --- src/xenconfig/xen_xl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index a06983e..db8cbf1 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -1068,7 +1068,7 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
/* devtype */ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) - virBufferAddLit(&buf, "devtype=cdrom,"); + virBufferAddLit(&buf, "devtype=cdrom");
This ...
/* * target @@ -1081,7 +1081,9 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk) if (xenFormatXLDiskSrc(disk->src, &target) < 0)
... would drop the comma leading the disk source in cases when the CDROM is actually full.
goto cleanup;
- virBufferAsprintf(&buf, "target=%s", target); + if (target) { + virBufferAsprintf(&buf, ",target=%s", target); + }
This fails syntax-check.

On Wed, Oct 19, 2016 at 13:20:09 +0200, Peter Krempa wrote:
On Wed, Oct 19, 2016 at 12:10:00 +0200, Cédric Bosdonnat wrote:
When converting a domain xml containing a CDROM device without any attached source, don't add a target=(null) to the libxl config disk definition: xen doesn't like it at all and would fail to start the domain. --- src/xenconfig/xen_xl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index a06983e..db8cbf1 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -1068,7 +1068,7 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
/* devtype */ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) - virBufferAddLit(&buf, "devtype=cdrom,"); + virBufferAddLit(&buf, "devtype=cdrom");
This ...
/* * target @@ -1081,7 +1081,9 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk) if (xenFormatXLDiskSrc(disk->src, &target) < 0)
... would drop the comma leading the disk source in cases when the CDROM is actually full.
Disregard this. I did not notice that 'target' is used to transfer the string.
goto cleanup;
- virBufferAsprintf(&buf, "target=%s", target); + if (target) { + virBufferAsprintf(&buf, ",target=%s", target); + }
This fails syntax-check.
ACK if you make sure that you run syntax-check before pushing.

On 10/19/2016 06:10 AM, Cédric Bosdonnat wrote:
When converting a domain xml containing a CDROM device without any attached source, don't add a target=(null) to the libxl config disk definition: xen doesn't like it at all and would fail to start the domain. --- src/xenconfig/xen_xl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
After your push, make check for xlconfigtest is now broken (at least on my Fedora run) John
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index a06983e..db8cbf1 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -1068,7 +1068,7 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
/* devtype */ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) - virBufferAddLit(&buf, "devtype=cdrom,"); + virBufferAddLit(&buf, "devtype=cdrom");
/* * target @@ -1081,7 +1081,9 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk) if (xenFormatXLDiskSrc(disk->src, &target) < 0) goto cleanup;
- virBufferAsprintf(&buf, "target=%s", target); + if (target) { + virBufferAsprintf(&buf, ",target=%s", target); + }
if (virBufferCheckError(&buf) < 0) goto cleanup;

On 20.10.2016 02:23, John Ferlan wrote:
On 10/19/2016 06:10 AM, Cédric Bosdonnat wrote:
When converting a domain xml containing a CDROM device without any attached source, don't add a target=(null) to the libxl config disk definition: xen doesn't like it at all and would fail to start the domain. --- src/xenconfig/xen_xl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
After your push, make check for xlconfigtest is now broken (at least on my Fedora run)
Moreover, while your subsequent patch fixes the tests, I think that your first patch was correct and the rest is broken. I mean we should have the following pattern: virBufferAdd(buf, "arg1"); if (cond1) virBufferAdd(buf, ",arg2"); if (cond2) virBufferAdd(buf, ",arg3"); and so on. Currently, the commas are after arg1, arg2, and arg3. Michal
participants (4)
-
Cédric Bosdonnat
-
John Ferlan
-
Michal Privoznik
-
Peter Krempa