[libvirt RFC PATCH 0/2] domxml-to-native: lower users' expectations

We do not support some configs that assume fd passing. Add a disclaimer to the API and the virsh command, and a bit frendlier error message to the vsock command line generator. (Alternatively, we could fill in some random values for the file descriptor numbers, just to give the user an idea what the command line would look like. But this still won't give them a functional equivalent of the command line. Which is not possible in all cases anyway) Ján Tomko (2): domxml-to-native: add disclaimer about fd passing qemu: error out if vsock does not have a pre-opened file descriptor docs/manpages/virsh.rst | 2 ++ src/libvirt-domain.c | 3 +++ src/qemu/qemu_command.c | 6 ++++++ 3 files changed, 11 insertions(+) -- 2.31.1

For some configs where FD passing is used, we cannot generate a corresponding native config without writing extra code just for domxml-to-native. Add a disclaimer to the API documentation and the virsh man page. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- docs/manpages/virsh.rst | 2 ++ src/libvirt-domain.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 20936994ce..673dc8f434 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -2532,6 +2532,8 @@ Convert the file *xml* into domain XML format or convert an existing *--domain* to the native guest configuration format named by *format*. The *xml* and *--domain* arguments are mutually exclusive. For the types of *format* argument, refer to ``domxml-from-native``. +Note that some domain configs cannot be converted to the native format, +because they rely on passing pre-opened file descriptors. dump diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 4eb14d4176..156939fe22 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -2675,6 +2675,9 @@ virConnectDomainXMLFromNative(virConnectPtr conn, * a native configuration file describing the domain. * The format of the native data is hypervisor dependent. * + * Note that some configs cannot be converted to the native format, + * because they rely on passing pre-opened file descriptors. + * * Returns a 0 terminated UTF-8 encoded native config datafile, or * NULL in case of error. The caller must free() the returned value. */ -- 2.31.1

This improves the error message when used with domxml-to-native from: error: internal error: invalid use of command API https://bugzilla.redhat.com/show_bug.cgi?id=1777212 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 156af4caee..f71f867942 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10291,6 +10291,12 @@ qemuBuildVsockCommandLine(virCommand *cmd, qemuDomainVsockPrivate *priv = (qemuDomainVsockPrivate *)vsock->privateData; g_autofree char *devstr = NULL; + if (priv->vhostfd == -1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("only pre-opened file descriptors are supported for vsock devices")); + return -1; + } + if (!(devstr = qemuBuildVsockDevStr(def, vsock, qemuCaps, ""))) return -1; -- 2.31.1

On Tue, Jul 27, 2021 at 01:52:30PM +0200, Ján Tomko wrote:
We do not support some configs that assume fd passing.
Add a disclaimer to the API and the virsh command, and a bit frendlier error message to the vsock command line generator.
(Alternatively, we could fill in some random values for the file descriptor numbers, just to give the user an idea what the command line would look like. But this still won't give them a functional equivalent of the command line. Which is not possible in all cases anyway)
I thought about passing in fake FD numbers to the XML formatting APIs before, but that risks us accidentally trying to close the fake FDs in error paths, so felt too dangerous. I think the safest we can do is to pass in NULL (or -1) for the pre-opened FDs, and whe we see that format a placeholder, eg literally generate --netdev tap,fd=FD-NUM to make it clear we've not provided a real FD and you have to replace the string "FD-NUM" with your own FD. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Daniel P. Berrangé
-
Ján Tomko