docs/manpages/virt-qemu-run.rst | 6 ++++++ src/libvirt_private.syms | 1 - src/qemu/qemu_shim.c | 36 +++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-)
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Add an option to ease setting up a VM with existing libvirt qemu.conf.
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1817776
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
docs/manpages/virt-qemu-run.rst | 6 ++++++
src/libvirt_private.syms | 1 -
src/qemu/qemu_shim.c | 36 +++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/docs/manpages/virt-qemu-run.rst b/docs/manpages/virt-qemu-run.rst
index b06c311b1d..3196b4c8f4 100644
--- a/docs/manpages/virt-qemu-run.rst
+++ b/docs/manpages/virt-qemu-run.rst
@@ -71,6 +71,12 @@ is a path to the XML description of the secret, whose UUID should
match a secret referenced in the guest domain XML. The ``VALUE-FILE``
is a path containing the raw value of the secret.
+``-c``, ``--with-config``
+
+Copy the libvirt qemu.conf configuration to the root directory. If
+there is already a qemu.conf file in the $ROOT/etc directory, exit
+with failure.
+
EXIT STATUS
===========
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 88fea4fc43..cb2b279401 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1899,7 +1899,6 @@ virConfWalk;
virConfWriteFile;
virConfWriteMem;
-
# util/vircrypto.h
virCryptoEncryptData;
virCryptoHashBuf;
diff --git a/src/qemu/qemu_shim.c b/src/qemu/qemu_shim.c
index 7e87b8fb96..553a37ab60 100644
--- a/src/qemu/qemu_shim.c
+++ b/src/qemu/qemu_shim.c
@@ -24,6 +24,7 @@
#include <stdbool.h>
#include <unistd.h>
+#include "virconf.h"
#include "virfile.h"
#include "virstring.h"
#include "virgettext.h"
@@ -99,6 +100,7 @@ int main(int argc, char **argv)
g_auto(GStrv) secrets = NULL;
gboolean verbose = false;
gboolean debug = false;
+ gboolean with_config = false;
GStrv tmpsecrets;
GOptionContext *ctx;
GOptionEntry entries[] = {
@@ -106,6 +108,7 @@ int main(int argc, char **argv)
{ "root", 'r', 0, G_OPTION_ARG_STRING, &root, "Root directory", "DIR" },
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, "Debug output", NULL },
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Verbose output", NULL },
+ { "with-config", 'c', 0, G_OPTION_ARG_NONE, &with_config, "Use system/home qemu.conf", NULL },
{ 0 }
};
int quitfd[2] = {-1, -1};
@@ -167,6 +170,39 @@ int main(int argc, char **argv)
}
}
+ if (with_config) {
+ g_autofree char *src = virConfLoadConfigPath("qemu.conf");
+ g_autofree char *dir = g_build_filename(root, "etc", NULL);
+ g_autofree char *dst = g_build_filename(dir, "qemu.conf", NULL);
+ g_autofree char *contents = NULL;
+ gsize len;
+
+ if (g_mkdir_with_parents(dir, 0755) < 0) {
+ g_printerr("%s: cannot create %s dir: %s\n",
+ argv[0], dir, g_strerror(errno));
+ goto cleanup;
+ }
+
+
+ if (g_file_test(dst, G_FILE_TEST_EXISTS)) {
+ g_printerr("%s: %s file already exists\n",
+ argv[0], dst);
+ goto cleanup;
+ }
+
+ if (!g_file_get_contents(src, &contents, &len, &error)) {
+ g_printerr("%s: cannot read %s: %s\n",
+ argv[0], src, error->message);
+ goto cleanup;
+ }
+
+ if (!g_file_set_contents(dst, contents, len, &error)) {
+ g_printerr("%s: cannot write %s: %s\n",
+ argv[0], dst, error->message);
+ goto cleanup;
+ }
+ }
+
virFileActivateDirOverrideForProg(argv[0]);
if (verbose)
--
2.26.0.rc2.42.g98cedd0233
On Sat, Mar 28, 2020 at 12:38:57AM +0100, marcandre.lureau@redhat.com wrote: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > Add an option to ease setting up a VM with existing libvirt qemu.conf. > > Fixes: > https://bugzilla.redhat.com/show_bug.cgi?id=1817776 > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > docs/manpages/virt-qemu-run.rst | 6 ++++++ > src/libvirt_private.syms | 1 - > src/qemu/qemu_shim.c | 36 +++++++++++++++++++++++++++++++++ > 3 files changed, 42 insertions(+), 1 deletion(-) > > diff --git a/docs/manpages/virt-qemu-run.rst b/docs/manpages/virt-qemu-run.rst > index b06c311b1d..3196b4c8f4 100644 > --- a/docs/manpages/virt-qemu-run.rst > +++ b/docs/manpages/virt-qemu-run.rst > @@ -71,6 +71,12 @@ is a path to the XML description of the secret, whose UUID should > match a secret referenced in the guest domain XML. The ``VALUE-FILE`` > is a path containing the raw value of the secret. > > +``-c``, ``--with-config`` > + > +Copy the libvirt qemu.conf configuration to the root directory. If > +there is already a qemu.conf file in the $ROOT/etc directory, exit > +with failure. As discussed in the bugzilla, we really don't want to be using the global qemu.conf file in combination with the embedded driver. We are not intending to guarantee that the embedded driver will share the same defaults as the global drivers. In general we want to eliminate the need to touch qemu.conf at all. 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 :|
Hi On Mon, Mar 30, 2020 at 1:54 PM Daniel P. Berrangé <berrange@redhat.com> wrote: > > On Sat, Mar 28, 2020 at 12:38:57AM +0100, marcandre.lureau@redhat.com wrote: > > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > > > Add an option to ease setting up a VM with existing libvirt qemu.conf. > > > > Fixes: > > https://bugzilla.redhat.com/show_bug.cgi?id=1817776 > > > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > > --- > > docs/manpages/virt-qemu-run.rst | 6 ++++++ > > src/libvirt_private.syms | 1 - > > src/qemu/qemu_shim.c | 36 +++++++++++++++++++++++++++++++++ > > 3 files changed, 42 insertions(+), 1 deletion(-) > > > > diff --git a/docs/manpages/virt-qemu-run.rst b/docs/manpages/virt-qemu-run.rst > > index b06c311b1d..3196b4c8f4 100644 > > --- a/docs/manpages/virt-qemu-run.rst > > +++ b/docs/manpages/virt-qemu-run.rst > > @@ -71,6 +71,12 @@ is a path to the XML description of the secret, whose UUID should > > match a secret referenced in the guest domain XML. The ``VALUE-FILE`` > > is a path containing the raw value of the secret. > > > > +``-c``, ``--with-config`` > > + > > +Copy the libvirt qemu.conf configuration to the root directory. If > > +there is already a qemu.conf file in the $ROOT/etc directory, exit > > +with failure. > > As discussed in the bugzilla, we really don't want to be using the > global qemu.conf file in combination with the embedded driver. We > are not intending to guarantee that the embedded driver will share > the same defaults as the global drivers. > > In general we want to eliminate the need to touch qemu.conf at all. With qemu:///embed, is the $root/etc/qemu.conf supposed to be user configurable? If not, then it should not even be accessed. Otherwise, having an option to ease setting it up would be welcome! If not from the user/system libvirt config, from a given path (for me, it will likely always be my user libvirt config anyway)
© 2016 - 2024 Red Hat, Inc.