Skip to contentSkip to conversation

Support qcow disks in GRUB

PATCH New Vladimir Serbinenko 1 participant 2 messages May 16, 2024 Kbuild

lore
Share & tools
lore
#1 lore raw

PATCH 2/2 Support qcow in grub-fstest

In reply to Vladimir Serbinenko
---
 util/grub-fstest.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
util/grub-fstest.c +9 -2
index 7ff9037b8..3c4fa26c6 100644
@@ -383,12 +383,14 @@ static int cmd = 0;
 static char *debug_str = NULL;
 static char **args = NULL;
 static int mount_crypt = 0;
+static int mount_qcow = 0;
 
 static void
 fstest (int n)
 {
   char *host_file;
   char *loop_name;
+  const char *loopback_cmd = mount_qcow ? "qcow" : "loopback";
   int i;
 
   for (i = 0; i < num_disks; i++)
@@ -405,8 +407,8 @@ fstest (int n)
       argv[0] = loop_name;
       argv[1] = host_file;
 
-      if (execute_command ("loopback", 2, argv))
-        grub_util_error (_("`loopback' command fails: %s"), grub_errmsg);
+      if (execute_command (loopback_cmd, 2, argv))
+        grub_util_error (_("`%s' command fails: %s"), loopback_cmd, grub_errmsg);
 
       grub_free (loop_name);
       grub_free (host_file);
@@ -530,6 +532,7 @@ static struct argp_option options[] = {
   {"diskcount", 'c', N_("NUM"),           0, N_("Specify the number of input files."),                   2},
   {"debug",     'd', N_("STRING"),           0, N_("Set debug environment variable."),  2},
   {"crypto",   'C', NULL, 0, N_("Mount crypto devices."), 2},
+  {"qcow",      'q', NULL, 0, N_("Mount qcow images."), 2},
   {"zfs-key",      'K',
    /* TRANSLATORS: "prompt" is a keyword.  */
    N_("FILE|prompt"), 0, N_("Load zfs crypto key."),                 2},
@@ -597,6 +600,10 @@ argp_parser (int key, char *arg, struct argp_state *state)
       mount_crypt = 1;
       return 0;
 
+    case 'q':
+      mount_qcow = 1;
+      return 0;
+
     case 's':
       skip = grub_strtoul (arg, &p, 0);
       if (*p == 's')
Signature · 7 lines
2.39.2


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#0 lore raw

PATCH 1/2 Support qcow disks in GRUB

---
 Makefile.util.def               |   1 +
 grub-core/Makefile.core.def     |   6 +
 grub-core/commands/nativedisk.c |   1 +
 grub-core/disk/qcow.c           | 464 ++++++++++++++++++++++++++++++++
 include/grub/disk.h             |   1 +
 5 files changed, 473 insertions(+)
 create mode 100644 grub-core/disk/qcow.c
Makefile.util.def +1 -0
index 9432365a9..d8b556afd 100644
@@ -71,6 +71,7 @@ library = {
   common = grub-core/commands/ls.c;
   common = grub-core/disk/dmraid_nvidia.c;
   common = grub-core/disk/loopback.c;
+  common = grub-core/disk/qcow.c;
   common = grub-core/disk/lvm.c;
   common = grub-core/disk/mdraid_linux.c;
   common = grub-core/disk/mdraid_linux_be.c;
grub-core/Makefile.core.def +6 -0
index 8e1b1d9f3..da65ba68c 100644
@@ -1204,6 +1204,12 @@ module = {
   common = disk/loopback.c;
 };
 
+module = {
+  name = qcow;
+  common = disk/qcow.c;
+  cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/zstd';
+};
+
 module = {
   name = cryptodisk;
   common = disk/cryptodisk.c;
grub-core/commands/nativedisk.c +1 -0
index 580c8d3b0..3e9bafac7 100644
@@ -98,6 +98,7 @@ get_uuid (const char *name, char **uuid, int getnative)
 
       /* FIXME: those probably need special handling.  */
     case GRUB_DISK_DEVICE_LOOPBACK_ID:
+    case GRUB_DISK_DEVICE_QCOW_ID:
     case GRUB_DISK_DEVICE_DISKFILTER_ID:
     case GRUB_DISK_DEVICE_CRYPTODISK_ID:
       break;
grub-core/disk/qcow.c new file +464 -0

464 lines not on this page · raw message

include/grub/disk.h +1 -0
index fbf23df7f..60bcd92be 100644
@@ -52,6 +52,7 @@ enum grub_disk_dev_id
     GRUB_DISK_DEVICE_UBOOTDISK_ID,
     GRUB_DISK_DEVICE_XEN,
     GRUB_DISK_DEVICE_OBDISK_ID,
+    GRUB_DISK_DEVICE_QCOW_ID,
   };
 
 struct grub_disk;
Signature · 7 lines
2.39.2


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel