qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 4/7] qemu: Transient option gets avaiable for qcow2 and ra


From: Masayoshi Mizuma
Subject: Re: [PATCH v2 4/7] qemu: Transient option gets avaiable for qcow2 and raw format disk
Date: Sun, 13 Sep 2020 08:37:39 -0400

On Tue, Sep 08, 2020 at 03:14:42PM +0200, Peter Krempa wrote:
> On Fri, Aug 28, 2020 at 10:08:33 -0400, Masayoshi Mizuma wrote:
> > From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> > 
> > Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> > ---
> >  src/qemu/qemu_validate.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
> > index 488f258d00..82818a4fdc 100644
> > --- a/src/qemu/qemu_validate.c
> > +++ b/src/qemu/qemu_validate.c
> > @@ -2166,9 +2166,12 @@ qemuValidateDomainDeviceDefDiskFrontend(const 
> > virDomainDiskDef *disk,
> >      }
> >  
> >      if (disk->transient) {
> > -        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> > -                       _("transient disks not supported yet"));
> > -        return -1;
> > +        if ((disk->src->format != VIR_STORAGE_FILE_QCOW2) &&
> > +            (disk->src->format != VIR_STORAGE_FILE_RAW)) {
> 
> This needs a check that QEMU_CAPS_BLOCKDEV is available as it won't
> really work properly in pre-blockdev config. Also here you
> should reject any other unsupported configuration rather than in the
> code.

Thanks. I'll add the following validation.

diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 070f1c962b..9cf78ca0c9 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -2002,6 +2002,28 @@ qemuValidateDomainDeviceDefDiskSerial(const char *value)
 }
 
 
+static int
+qemuValidateDomainDeviceDefDiskTransient(const virDomainDiskDef *disk,
+                                         virQEMUCapsPtr qemuCaps)
+{
+    if ((!qemuCaps) || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV))
+        return false;
+
+    if (disk->src->readonly)
+        return false;
+
+    if ((disk->src->format != VIR_STORAGE_FILE_QCOW2) &&
+        (disk->src->format != VIR_STORAGE_FILE_RAW) &&
+        (disk->src->type != VIR_STORAGE_TYPE_FILE)) {
+        return false;
+    }
+
+    if (virStorageSourceIsEmpty(disk->src))
+        return false;
+
+    return true;
+}
+
 static int
 qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk,
                                         virQEMUCapsPtr qemuCaps)
@@ -2186,7 +2208,8 @@ qemuValidateDomainDeviceDefDiskFrontend(const 
virDomainDiskDef *disk,
         }
     }
 
-    if (disk->transient) {
+    if ((disk->transient) &&
+        !qemuValidateDomainDeviceDefDiskTransient(disk, qemuCaps)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("transient disks not supported yet"));
         return -1;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]