[libvirt] [PATCH v2 15/29] conf: Replace virDomainDiskSourceParse by virDomainStorageSourceParse

Peter Krempa posted 29 patches 6 years, 10 months ago
[libvirt] [PATCH v2 15/29] conf: Replace virDomainDiskSourceParse by virDomainStorageSourceParse
Posted by Peter Krempa 6 years, 10 months ago
virDomainDiskSourceParse was now just a thin wrapper without any extra
value. Replace all usage of it by the function it calls and remove the
function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/conf/domain_conf.c   | 22 ++++------------------
 src/conf/domain_conf.h   |  5 -----
 src/conf/snapshot_conf.c |  2 +-
 tests/qemublocktest.c    |  2 +-
 4 files changed, 6 insertions(+), 25 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fa50b6f000..c93c4df929 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9111,20 +9111,6 @@ virDomainStorageSourceParse(xmlNodePtr node,
 }


-int
-virDomainDiskSourceParse(xmlNodePtr node,
-                         xmlXPathContextPtr ctxt,
-                         virStorageSourcePtr src,
-                         unsigned int flags,
-                         virDomainXMLOptionPtr xmlopt)
-{
-    if (virDomainStorageSourceParse(node, ctxt, src, flags, xmlopt) < 0)
-        return -1;
-
-    return 0;
-}
-
-
 static int
 virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
                                virStorageSourcePtr src,
@@ -9186,7 +9172,7 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
         return -1;
     }

-    if (virDomainDiskSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||
+    if (virDomainStorageSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||
         virDomainDiskBackingStoreParse(ctxt, backingStore, flags, xmlopt) < 0)
         return -1;

@@ -9320,8 +9306,8 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def,
             return -1;
         }

-        if (virDomainDiskSourceParse(mirrorNode, ctxt, def->mirror,
-                                     flags, xmlopt) < 0)
+        if (virDomainStorageSourceParse(mirrorNode, ctxt, def->mirror,
+                                        flags, xmlopt) < 0)
             return -1;
     } else {
         /* For back-compat reasons, we handle a file name
@@ -9771,7 +9757,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
             continue;

         if (!source && virXMLNodeNameEqual(cur, "source")) {
-            if (virDomainDiskSourceParse(cur, ctxt, def->src, flags, xmlopt) < 0)
+            if (virDomainStorageSourceParse(cur, ctxt, def->src, flags, xmlopt) < 0)
                 goto error;

             /* If we've already found an <auth> as a child of <disk> and
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index cca81be013..f550c257d6 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3067,11 +3067,6 @@ virDomainDiskDefPtr
 virDomainDiskRemove(virDomainDefPtr def, size_t i);
 virDomainDiskDefPtr
 virDomainDiskRemoveByName(virDomainDefPtr def, const char *name);
-int virDomainDiskSourceParse(xmlNodePtr node,
-                             xmlXPathContextPtr ctxt,
-                             virStorageSourcePtr src,
-                             unsigned int flags,
-                             virDomainXMLOptionPtr xmlopt);

 int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
 virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 58d2cfee99..93b5bafcd6 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -146,7 +146,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
     }

     if ((cur = virXPathNode("./source", ctxt)) &&
-        virDomainDiskSourceParse(cur, ctxt, def->src, flags, xmlopt) < 0)
+        virDomainStorageSourceParse(cur, ctxt, def->src, flags, xmlopt) < 0)
         goto cleanup;

     if ((driver = virXPathString("string(./driver/@type)", ctxt)) &&
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 46e75c2df5..1a365a411c 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -62,7 +62,7 @@ testBackingXMLjsonXML(const void *args)
     if (!(xml = virXMLParseStringCtxt(data->xml, "(test storage source XML)", &ctxt)))
         return -1;

-    if (virDomainDiskSourceParse(ctxt->node, ctxt, xmlsrc, 0, NULL) < 0) {
+    if (virDomainStorageSourceParse(ctxt->node, ctxt, xmlsrc, 0, NULL) < 0) {
         fprintf(stderr, "failed to parse disk source xml\n");
         return -1;
     }
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 15/29] conf: Replace virDomainDiskSourceParse by virDomainStorageSourceParse
Posted by Ján Tomko 6 years, 10 months ago
On Fri, Mar 22, 2019 at 07:00:51PM +0100, Peter Krempa wrote:
>virDomainDiskSourceParse was now just a thin wrapper without any extra
>value. Replace all usage of it by the function it calls and remove the
>function.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/conf/domain_conf.c   | 22 ++++------------------
> src/conf/domain_conf.h   |  5 -----
> src/conf/snapshot_conf.c |  2 +-
> tests/qemublocktest.c    |  2 +-
> 4 files changed, 6 insertions(+), 25 deletions(-)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index fa50b6f000..c93c4df929 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -9186,7 +9172,7 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
>         return -1;
>     }
>
>-    if (virDomainDiskSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||
>+    if (virDomainStorageSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||

Hmm, so we have virDomainStorageSourceParse and a corresponding
virDomainDiskSourceFormat?

Maybe the previous commit dropped the wrong function.

>         virDomainDiskBackingStoreParse(ctxt, backingStore, flags, xmlopt) < 0)
>         return -1;
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 15/29] conf: Replace virDomainDiskSourceParse by virDomainStorageSourceParse
Posted by Peter Krempa 6 years, 10 months ago
On Tue, Apr 02, 2019 at 09:35:36 +0200, Ján Tomko wrote:
> On Fri, Mar 22, 2019 at 07:00:51PM +0100, Peter Krempa wrote:
> > virDomainDiskSourceParse was now just a thin wrapper without any extra
> > value. Replace all usage of it by the function it calls and remove the
> > function.
> > 
> > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > ---
> > src/conf/domain_conf.c   | 22 ++++------------------
> > src/conf/domain_conf.h   |  5 -----
> > src/conf/snapshot_conf.c |  2 +-
> > tests/qemublocktest.c    |  2 +-
> > 4 files changed, 6 insertions(+), 25 deletions(-)
> > 
> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> > index fa50b6f000..c93c4df929 100644
> > --- a/src/conf/domain_conf.c
> > +++ b/src/conf/domain_conf.c
> > @@ -9186,7 +9172,7 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
> >         return -1;
> >     }
> > 
> > -    if (virDomainDiskSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||
> > +    if (virDomainStorageSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||
> 
> Hmm, so we have virDomainStorageSourceParse and a corresponding
> virDomainDiskSourceFormat?
> 
> Maybe the previous commit dropped the wrong function.

Should I rename virDomainDiskSourceFormat to virDomainStorageSourceFormat
in an upcomming patch?

> 
> >         virDomainDiskBackingStoreParse(ctxt, backingStore, flags, xmlopt) < 0)
> >         return -1;
> > 
> 
> Reviewed-by: Ján Tomko <jtomko@redhat.com>
> 
> Jano



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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 15/29] conf: Replace virDomainDiskSourceParse by virDomainStorageSourceParse
Posted by Ján Tomko 6 years, 10 months ago
On Tue, Apr 02, 2019 at 02:09:24PM +0200, Peter Krempa wrote:
>On Tue, Apr 02, 2019 at 09:35:36 +0200, Ján Tomko wrote:
>> On Fri, Mar 22, 2019 at 07:00:51PM +0100, Peter Krempa wrote:
>> > virDomainDiskSourceParse was now just a thin wrapper without any extra
>> > value. Replace all usage of it by the function it calls and remove the
>> > function.
>> >
>> > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>> > ---
>> > src/conf/domain_conf.c   | 22 ++++------------------
>> > src/conf/domain_conf.h   |  5 -----
>> > src/conf/snapshot_conf.c |  2 +-
>> > tests/qemublocktest.c    |  2 +-
>> > 4 files changed, 6 insertions(+), 25 deletions(-)
>> >
>> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> > index fa50b6f000..c93c4df929 100644
>> > --- a/src/conf/domain_conf.c
>> > +++ b/src/conf/domain_conf.c
>> > @@ -9186,7 +9172,7 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
>> >         return -1;
>> >     }
>> >
>> > -    if (virDomainDiskSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||
>> > +    if (virDomainStorageSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||
>>
>> Hmm, so we have virDomainStorageSourceParse and a corresponding
>> virDomainDiskSourceFormat?
>>
>> Maybe the previous commit dropped the wrong function.
>
>Should I rename virDomainDiskSourceFormat to virDomainStorageSourceFormat
>in an upcomming patch?
>

Please do.

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