[RFC PATCH 2/7] qemuMigrationCookieNBDXMLFormat: Format empty <nbd/> element

Peter Krempa posted 7 patches 4 years, 10 months ago
[RFC PATCH 2/7] qemuMigrationCookieNBDXMLFormat: Format empty <nbd/> element
Posted by Peter Krempa 4 years, 10 months ago
Commit 518be41aaa3 refactored qemuMigrationCookieNBDXMLFormat to use
virXMLFormatElement which in comparison to the previous code doesn't
format the element if it's empty.

Unfortunately some crusty bits of our migration code use questionable
logic to assert use of the old-style storage migration parameters which
breaks if no disks are being migrated and the <nbd/> element is not
present.

While later patches will fix the code, re-instate formatting of empty
<nbd/> for increased compatibility.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_migration_cookie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 41533e4549..52998ddd1b 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -790,7 +790,7 @@ qemuMigrationCookieNBDXMLFormat(qemuMigrationCookieNBD *nbd,
         virBufferAsprintf(&childBuf, " capacity='%llu'/>\n", nbd->disks[i].capacity);
     }

-    virXMLFormatElement(buf, "nbd", &attrBuf, &childBuf);
+    virXMLFormatElementEmpty(buf, "nbd", &attrBuf, &childBuf);
 }


-- 
2.30.2

Re: [RFC PATCH 2/7] qemuMigrationCookieNBDXMLFormat: Format empty <nbd/> element
Posted by Andrea Bolognani 4 years, 10 months ago
On Tue, 2021-04-13 at 17:38 +0200, Peter Krempa wrote:
> -    virXMLFormatElement(buf, "nbd", &attrBuf, &childBuf);
> +    virXMLFormatElementEmpty(buf, "nbd", &attrBuf, &childBuf);

The explanation in the commit message is good, but I think having at
least a very short nod in the code itself would be nice.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization