[libvirt] [PATCHv2 13/62] qemu: monitor: Add 'nodename' argument for 'block_resize'

Peter Krempa posted 62 patches 7 years, 5 months ago
[libvirt] [PATCHv2 13/62] qemu: monitor: Add 'nodename' argument for 'block_resize'
Posted by Peter Krempa 7 years, 5 months ago
Allow referring to individual node name to rezise.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_driver.c       |  2 +-
 src/qemu/qemu_monitor.c      | 12 ++++++++++--
 src/qemu/qemu_monitor.h      |  3 ++-
 src/qemu/qemu_monitor_json.c |  4 +++-
 src/qemu/qemu_monitor_json.h |  3 ++-
 tests/qemumonitorjsontest.c  |  2 +-
 6 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d11e990443..7456db6468 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10991,7 +10991,7 @@ qemuDomainBlockResize(virDomainPtr dom,
         goto endjob;

     qemuDomainObjEnterMonitor(driver, vm);
-    if (qemuMonitorBlockResize(priv->mon, device, size) < 0) {
+    if (qemuMonitorBlockResize(priv->mon, device, NULL, size) < 0) {
         ignore_value(qemuDomainObjExitMonitor(driver, vm));
         goto endjob;
     }
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 758942ffcb..4dcbd69dce 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2312,13 +2312,21 @@ qemuMonitorBlockStatsUpdateCapacity(qemuMonitorPtr mon,
 int
 qemuMonitorBlockResize(qemuMonitorPtr mon,
                        const char *device,
+                       const char *nodename,
                        unsigned long long size)
 {
-    VIR_DEBUG("device=%s size=%llu", device, size);
+    VIR_DEBUG("device=%s nodename=%s size=%llu",
+              NULLSTR(device), NULLSTR(nodename), size);

     QEMU_CHECK_MONITOR(mon);

-    return qemuMonitorJSONBlockResize(mon, device, size);
+    if ((!device && !nodename) || (device && nodename)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("exactly one of 'device' and 'nodename' need to be specified"));
+        return -1;
+    }
+
+    return qemuMonitorJSONBlockResize(mon, device, nodename, size);
 }


diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 60418422e9..f8f6969ddb 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -596,7 +596,8 @@ int qemuMonitorBlockStatsUpdateCapacity(qemuMonitorPtr mon,
     ATTRIBUTE_NONNULL(2);

 int qemuMonitorBlockResize(qemuMonitorPtr mon,
-                           const char *dev_name,
+                           const char *device,
+                           const char *nodename,
                            unsigned long long size);
 int qemuMonitorSetVNCPassword(qemuMonitorPtr mon,
                               const char *password);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index e43447dc53..de3fcd83d8 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2542,6 +2542,7 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon,

 int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
                                const char *device,
+                               const char *nodename,
                                unsigned long long size)
 {
     int ret = -1;
@@ -2549,7 +2550,8 @@ int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
     virJSONValuePtr reply = NULL;

     cmd = qemuMonitorJSONMakeCommand("block_resize",
-                                     "s:device", device,
+                                     "S:device", device,
+                                     "S:node-name", nodename,
                                      "U:size", size,
                                      NULL);
     if (!cmd)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 4d75e04183..19aebef5fb 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -94,7 +94,8 @@ int qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon,
                                             virHashTablePtr stats,
                                             bool backingChain);
 int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
-                               const char *devce,
+                               const char *device,
+                               const char *nodename,
                                unsigned long long size);

 int qemuMonitorJSONSetVNCPassword(qemuMonitorPtr mon,
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 35d24cfb22..3da4d3076a 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1320,7 +1320,7 @@ cleanup: \
 }

 GEN_TEST_FUNC(qemuMonitorJSONSetLink, "vnet0", VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN)
-GEN_TEST_FUNC(qemuMonitorJSONBlockResize, "vda", 123456)
+GEN_TEST_FUNC(qemuMonitorJSONBlockResize, "vda", "asdf", 123456)
 GEN_TEST_FUNC(qemuMonitorJSONSetVNCPassword, "secret_password")
 GEN_TEST_FUNC(qemuMonitorJSONSetPassword, "spice", "secret_password", "disconnect")
 GEN_TEST_FUNC(qemuMonitorJSONExpirePassword, "spice", "123456")
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv2 13/62] qemu: monitor: Add 'nodename' argument for 'block_resize'
Posted by Ján Tomko 7 years, 5 months ago
On Mon, Aug 13, 2018 at 05:59:47PM +0200, Peter Krempa wrote:
>Allow referring to individual node name to rezise.

s/rezise/resize/

>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_driver.c       |  2 +-
> src/qemu/qemu_monitor.c      | 12 ++++++++++--
> src/qemu/qemu_monitor.h      |  3 ++-
> src/qemu/qemu_monitor_json.c |  4 +++-
> src/qemu/qemu_monitor_json.h |  3 ++-
> tests/qemumonitorjsontest.c  |  2 +-
> 6 files changed, 19 insertions(+), 7 deletions(-)
>
>diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
>index 35d24cfb22..3da4d3076a 100644
>--- a/tests/qemumonitorjsontest.c
>+++ b/tests/qemumonitorjsontest.c
>@@ -1320,7 +1320,7 @@ cleanup: \
> }
>
> GEN_TEST_FUNC(qemuMonitorJSONSetLink, "vnet0", VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN)
>-GEN_TEST_FUNC(qemuMonitorJSONBlockResize, "vda", 123456)
>+GEN_TEST_FUNC(qemuMonitorJSONBlockResize, "vda", "asdf", 123456)

Good to see you lead by example and only specified one of the two.

> GEN_TEST_FUNC(qemuMonitorJSONSetVNCPassword, "secret_password")
> GEN_TEST_FUNC(qemuMonitorJSONSetPassword, "spice", "secret_password", "disconnect")
> GEN_TEST_FUNC(qemuMonitorJSONExpirePassword, "spice", "123456")

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] [PATCHv2 13/62] qemu: monitor: Add 'nodename' argument for 'block_resize'
Posted by Peter Krempa 7 years, 5 months ago
On Wed, Aug 15, 2018 at 10:43:23 +0200, Ján Tomko wrote:
> On Mon, Aug 13, 2018 at 05:59:47PM +0200, Peter Krempa wrote:
> > Allow referring to individual node name to rezise.
> 
> s/rezise/resize/
> 
> > 
> > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > ---
> > src/qemu/qemu_driver.c       |  2 +-
> > src/qemu/qemu_monitor.c      | 12 ++++++++++--
> > src/qemu/qemu_monitor.h      |  3 ++-
> > src/qemu/qemu_monitor_json.c |  4 +++-
> > src/qemu/qemu_monitor_json.h |  3 ++-
> > tests/qemumonitorjsontest.c  |  2 +-
> > 6 files changed, 19 insertions(+), 7 deletions(-)
> > 
> > diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
> > index 35d24cfb22..3da4d3076a 100644
> > --- a/tests/qemumonitorjsontest.c
> > +++ b/tests/qemumonitorjsontest.c
> > @@ -1320,7 +1320,7 @@ cleanup: \
> > }
> > 
> > GEN_TEST_FUNC(qemuMonitorJSONSetLink, "vnet0", VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN)
> > -GEN_TEST_FUNC(qemuMonitorJSONBlockResize, "vda", 123456)
> > +GEN_TEST_FUNC(qemuMonitorJSONBlockResize, "vda", "asdf", 123456)
> 
> Good to see you lead by example and only specified one of the two.

Well, the purpose here is to force schema detection to validate that the
given argument is present in the QAPI schema in a very simple way.

The schema can't express exclusivity of those two so we are okay at this
point and we can be certain that the field names are correct.

Unfortunately the GEN_TEST_FUNC macro is not flexible enough to allow
multiple invocations.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list