[libvirt] [PATCH] qemu: Prepare BIOS/UEFI when starting a domain

Michal Privoznik posted 1 patch 6 years, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/6c2d6a680990bf239fee517445d129523336290b.1514964030.git.mprivozn@redhat.com
src/qemu/qemu_domain.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
[libvirt] [PATCH] qemu: Prepare BIOS/UEFI when starting a domain
Posted by Michal Privoznik 6 years, 3 months ago
https://bugzilla.redhat.com/show_bug.cgi?id=1527740

Users might use a block device as UEFI VAR store. Or even have
OVMF stored there. Therefore, when starting a domain and separate
mount namespace is used, we have to create all the /dev entries
that are configured for the domain.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_domain.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 43bd0fff4..04af68809 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9470,6 +9470,44 @@ qemuDomainSetupAllRNGs(virQEMUDriverConfigPtr cfg,
 }
 
 
+static int
+qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
+                      virDomainObjPtr vm,
+                      const struct qemuDomainCreateDeviceData *data)
+{
+    virDomainLoaderDefPtr loader = vm->def->os.loader;
+    int ret = -1;
+
+    VIR_DEBUG("Setting up loader");
+
+    if (loader) {
+        switch ((virDomainLoader) loader->type) {
+        case VIR_DOMAIN_LOADER_TYPE_ROM:
+            if (qemuDomainCreateDevice(loader->path, data, false) < 0)
+                goto cleanup;
+            break;
+
+        case VIR_DOMAIN_LOADER_TYPE_PFLASH:
+            if (qemuDomainCreateDevice(loader->path, data, false) < 0)
+                goto cleanup;
+
+            if (loader->nvram &&
+                qemuDomainCreateDevice(loader->nvram, data, false) < 0)
+                goto cleanup;
+            break;
+
+        case VIR_DOMAIN_LOADER_TYPE_LAST:
+            break;
+        }
+    }
+
+    VIR_DEBUG("Setup loader");
+    ret = 0;
+ cleanup:
+    return ret;
+}
+
+
 int
 qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
                          virSecurityManagerPtr mgr,
@@ -9538,6 +9576,9 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
     if (qemuDomainSetupAllRNGs(cfg, vm, &data) < 0)
         goto cleanup;
 
+    if (qemuDomainSetupLoader(cfg, vm, &data) < 0)
+        goto cleanup;
+
     /* Save some mount points because we want to share them with the host */
     for (i = 0; i < ndevMountsPath; i++) {
         struct stat sb;
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Prepare BIOS/UEFI when starting a domain
Posted by John Ferlan 6 years, 3 months ago

On 01/03/2018 02:20 AM, Michal Privoznik wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1527740
> 
> Users might use a block device as UEFI VAR store. Or even have
> OVMF stored there. Therefore, when starting a domain and separate
> mount namespace is used, we have to create all the /dev entries
> that are configured for the domain.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_domain.c | 41 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list