diff mbox

[2/2] hmp: Extend drive_del to delete nodes without BB

Message ID 1456247799-9593-3-git-send-email-kwolf@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kevin Wolf Feb. 23, 2016, 5:16 p.m. UTC
Now that we can use drive_add to create new nodes without a BB, we also
want to be able to delete such nodes again.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 blockdev.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Max Reitz Feb. 24, 2016, 5:54 p.m. UTC | #1
On 23.02.2016 18:16, Kevin Wolf wrote:
> Now that we can use drive_add to create new nodes without a BB, we also
> want to be able to delete such nodes again.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  blockdev.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 3f46bc1..b76b6cd 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -2816,6 +2816,15 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
>      AioContext *aio_context;
>      Error *local_err = NULL;
>  
> +    bs = bdrv_find_node(id);
> +    if (bs) {
> +        qmp_x_blockdev_del(false, NULL, true, id, &local_err);
> +        if (local_err) {
> +            error_report_err(local_err);
> +        }
> +        return;
> +    }
> +
>      blk = blk_by_name(id);
>      if (!blk) {
>          error_report("Device '%s' not found", id);
> 

It's a bit strange to require the user to specify the node name using
"node-name" for drive_add, but the to use "id" in drive_del; especially
because x-blockdev-del uses "node-name", too.

Up to your discretion.

Reviewed-by: Max Reitz <mreitz@redhat.com>
Kevin Wolf Feb. 24, 2016, 6:23 p.m. UTC | #2
Am 24.02.2016 um 18:54 hat Max Reitz geschrieben:
> On 23.02.2016 18:16, Kevin Wolf wrote:
> > Now that we can use drive_add to create new nodes without a BB, we also
> > want to be able to delete such nodes again.
> > 
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  blockdev.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/blockdev.c b/blockdev.c
> > index 3f46bc1..b76b6cd 100644
> > --- a/blockdev.c
> > +++ b/blockdev.c
> > @@ -2816,6 +2816,15 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
> >      AioContext *aio_context;
> >      Error *local_err = NULL;
> >  
> > +    bs = bdrv_find_node(id);
> > +    if (bs) {
> > +        qmp_x_blockdev_del(false, NULL, true, id, &local_err);
> > +        if (local_err) {
> > +            error_report_err(local_err);
> > +        }
> > +        return;
> > +    }
> > +
> >      blk = blk_by_name(id);
> >      if (!blk) {
> >          error_report("Device '%s' not found", id);
> > 
> 
> It's a bit strange to require the user to specify the node name using
> "node-name" for drive_add, but the to use "id" in drive_del; especially
> because x-blockdev-del uses "node-name", too.

Not sure I understand. For the user of drive_del that's simply a
positional parameter, so they use neither "id" nor "node-name". Am I
missing something?

Kevin

> Up to your discretion.
> 
> Reviewed-by: Max Reitz <mreitz@redhat.com>
>
Peter Krempa Feb. 25, 2016, 12:51 p.m. UTC | #3
On Wed, Feb 24, 2016 at 18:54:45 +0100, Max Reitz wrote:
> On 23.02.2016 18:16, Kevin Wolf wrote:
> > Now that we can use drive_add to create new nodes without a BB, we also
> > want to be able to delete such nodes again.
> > 
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  blockdev.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)

[..]

> > 
> 
> It's a bit strange to require the user to specify the node name using
> "node-name" for drive_add, but the to use "id" in drive_del; especially
> because x-blockdev-del uses "node-name", too.

Well, since 'x-blockdev-del' is considered unstable yet I can't really
use it in libvirt, thus we discussed using drive_del as a workaround.

It makes partially sense since we'd add the new node with 'drive_add' in
the first place.

Peter
Max Reitz Feb. 26, 2016, 1:09 p.m. UTC | #4
On 24.02.2016 19:23, Kevin Wolf wrote:
> Am 24.02.2016 um 18:54 hat Max Reitz geschrieben:
>> On 23.02.2016 18:16, Kevin Wolf wrote:
>>> Now that we can use drive_add to create new nodes without a BB, we also
>>> want to be able to delete such nodes again.
>>>
>>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>>> ---
>>>  blockdev.c | 9 +++++++++
>>>  1 file changed, 9 insertions(+)
>>>
>>> diff --git a/blockdev.c b/blockdev.c
>>> index 3f46bc1..b76b6cd 100644
>>> --- a/blockdev.c
>>> +++ b/blockdev.c
>>> @@ -2816,6 +2816,15 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
>>>      AioContext *aio_context;
>>>      Error *local_err = NULL;
>>>  
>>> +    bs = bdrv_find_node(id);
>>> +    if (bs) {
>>> +        qmp_x_blockdev_del(false, NULL, true, id, &local_err);
>>> +        if (local_err) {
>>> +            error_report_err(local_err);
>>> +        }
>>> +        return;
>>> +    }
>>> +
>>>      blk = blk_by_name(id);
>>>      if (!blk) {
>>>          error_report("Device '%s' not found", id);
>>>
>>
>> It's a bit strange to require the user to specify the node name using
>> "node-name" for drive_add, but the to use "id" in drive_del; especially
>> because x-blockdev-del uses "node-name", too.
> 
> Not sure I understand. For the user of drive_del that's simply a
> positional parameter, so they use neither "id" nor "node-name". Am I
> missing something?

No, it's just me being confused again by the way HMP works. I keep
forgetting that the user doesn't specify the parameter names. So the R-b
stands. :-)

Max
Max Reitz Feb. 26, 2016, 1:11 p.m. UTC | #5
On 25.02.2016 13:51, Peter Krempa wrote:
> On Wed, Feb 24, 2016 at 18:54:45 +0100, Max Reitz wrote:
>> On 23.02.2016 18:16, Kevin Wolf wrote:
>>> Now that we can use drive_add to create new nodes without a BB, we also
>>> want to be able to delete such nodes again.
>>>
>>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>>> ---
>>>  blockdev.c | 9 +++++++++
>>>  1 file changed, 9 insertions(+)
> 
> [..]
> 
>>>
>>
>> It's a bit strange to require the user to specify the node name using
>> "node-name" for drive_add, but the to use "id" in drive_del; especially
>> because x-blockdev-del uses "node-name", too.
> 
> Well, since 'x-blockdev-del' is considered unstable yet I can't really
> use it in libvirt, thus we discussed using drive_del as a workaround.
> 
> It makes partially sense since we'd add the new node with 'drive_add' in
> the first place.

Yes, you're right. However, my question was solely about the parameter
name (reusing "id" for a node name). As Kevin replied, for HMP the
parameter name doesn't really matter to the user anyway, so reusing the
"id" parameter here is completely fine.

Max
diff mbox

Patch

diff --git a/blockdev.c b/blockdev.c
index 3f46bc1..b76b6cd 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2816,6 +2816,15 @@  void hmp_drive_del(Monitor *mon, const QDict *qdict)
     AioContext *aio_context;
     Error *local_err = NULL;
 
+    bs = bdrv_find_node(id);
+    if (bs) {
+        qmp_x_blockdev_del(false, NULL, true, id, &local_err);
+        if (local_err) {
+            error_report_err(local_err);
+        }
+        return;
+    }
+
     blk = blk_by_name(id);
     if (!blk) {
         error_report("Device '%s' not found", id);