[libvirt] [RFC 6/7] Deprecate missing machine type in virDomainDefineXMLFlags()

Andrea Bolognani posted 7 patches 4 years, 8 months ago
[libvirt] [RFC 6/7] Deprecate missing machine type in virDomainDefineXMLFlags()
Posted by Andrea Bolognani 4 years, 8 months ago
This time we don't want to deprecate the API itself; instead,
we want warning to be reported whenever some specific condition
is met.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 src/conf/domain_conf.c | 11 ++++++++---
 src/libvirt-domain.c   |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9911d56130..da0f1ed025 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19114,9 +19114,14 @@ virDomainDefParseCaps(virDomainDefPtr def,
     } else {
         if (!def->os.arch)
             def->os.arch = capsdata->arch;
-        if ((!def->os.machine &&
-             VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0))
-            goto cleanup;
+        if (!def->os.machine) {
+            virReportWarning(VIR_ERR_DEPRECATED_FEATURE,
+                             "%s",
+                             _("Missing machine type"));
+
+            if (VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0)
+                goto cleanup;
+        }
     }
 
     ret = 0;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index a758539b6d..be1a67d8f6 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -6216,6 +6216,7 @@ virDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
         ret = conn->driver->domainDefineXMLFlags(conn, xml, flags);
         if (!ret)
             goto error;
+        virDispatchError(conn);
         return ret;
     }
 
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC 6/7] Deprecate missing machine type in virDomainDefineXMLFlags()
Posted by Peter Krempa 4 years, 8 months ago
On Tue, Oct 02, 2018 at 16:14:45 +0200, Andrea Bolognani wrote:
> This time we don't want to deprecate the API itself; instead,
> we want warning to be reported whenever some specific condition
> is met.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  src/conf/domain_conf.c | 11 ++++++++---
>  src/libvirt-domain.c   |  1 +
>  2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 9911d56130..da0f1ed025 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -19114,9 +19114,14 @@ virDomainDefParseCaps(virDomainDefPtr def,
>      } else {
>          if (!def->os.arch)
>              def->os.arch = capsdata->arch;
> -        if ((!def->os.machine &&
> -             VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0))
> -            goto cleanup;
> +        if (!def->os.machine) {
> +            virReportWarning(VIR_ERR_DEPRECATED_FEATURE,
> +                             "%s",
> +                             _("Missing machine type"));

Soo, and if multiple warnings are present? Since we don't support
multiple error objects this will create one warning and after you fix it
a second one.

Also I doubt that LXC has a machine type.


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC 6/7] Deprecate missing machine type in virDomainDefineXMLFlags()
Posted by Andrea Bolognani 4 years, 8 months ago
On Tue, 2018-10-02 at 16:48 +0200, Peter Krempa wrote:
> On Tue, Oct 02, 2018 at 16:14:45 +0200, Andrea Bolognani wrote:
[...]
> > @@ -19114,9 +19114,14 @@ virDomainDefParseCaps(virDomainDefPtr def,
> >      } else {
> >          if (!def->os.arch)
> >              def->os.arch = capsdata->arch;
> > -        if ((!def->os.machine &&
> > -             VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0))
> > -            goto cleanup;
> > +        if (!def->os.machine) {
> > +            virReportWarning(VIR_ERR_DEPRECATED_FEATURE,
> > +                             "%s",
> > +                             _("Missing machine type"));
> 
> Soo, and if multiple warnings are present? Since we don't support
> multiple error objects this will create one warning and after you fix it
> a second one.

I don't think that's necessarily a blocker: a similar behavior can
be observed by feeding libvirt a guest definition that contains two
or more errors, in which case you're expected to solve them one at
the time; you could very well do the same for warnings.

> Also I doubt that LXC has a machine type.

That could be addressed by reporting the warning from the QEMU
driver instead of the generic code. Doing so would probably require
shuffling the calls around quite a bit, but I don't see why it
wouldn't be possible.

-- 
Andrea Bolognani / Red Hat / Virtualization

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