Skip to contentSkip to conversation

export root node for write through NBD

Qemu-devel Vladimir Sementsov-Ogievskiy 3 participants 4 messages Nov 30, 2017 – Dec 15, 2017 Block layer

lore
Share & tools
lore
#0 lore raw

Hi all.

We need the following option: start vm in stopped mode (-S) and write it's disk before start through NBD. It should be absolutely safe, but unfortunately it is disallowed by root role of the disk. Is there any workaround or if not, what is a true way to implement this possibility?

----
error message:
    unable to execute QEMU command 'nbd-server-add': Conflicts with use by drive0 as 'root', which does not allow 'write' on #block100

Signature · 2 lines
Best regards,
Vladimir
#1 lore raw
Quoted 9 lines · Vladimir Sementsov-Ogievskiy

Hi all.

We need the following option: start vm in stopped mode (-S) and write it's disk before start through NBD.
It should be absolutely safe, but unfortunately it is disallowed by root role of the disk.
Is there any workaround or if not, what is a true way to implement this possibility?

Quoted 6 lines

----
error message:
    unable to execute QEMU command 'nbd-server-add': Conflicts with use by drive0 as 'root', which does not allow 'write' on #block100

One thing that comes to mind is adding the guest device only after you are done with NBD.

The other of course is to set share-rw=on for the device.

Max

#2 lore raw

Am 30.11.2017 um 15:21 hat Max Reitz geschrieben:

Quoted 15 lines · Vladimir Sementsov-Ogievskiy
Quoted 9 lines

Hi all.

We need the following option: start vm in stopped mode (-S) and write it's disk before start through NBD.
It should be absolutely safe, but unfortunately it is disallowed by root role of the disk.
Is there any workaround or if not, what is a true way to implement this possibility?

Quoted 4 lines

----
error message:
    unable to execute QEMU command 'nbd-server-add': Conflicts with use by drive0 as 'root', which does not allow 'write' on #block100

Quoted 4 lines

One thing that comes to mind is adding the guest device only after you are done with NBD.

The other of course is to set share-rw=on for the device.

We already allow this with incoming migration, in that case the BlockBackend for the guest device stays inactive and doesn't request permissions yet.

I've been thinking for a while that it would be nice to unify the startup of "normal" VMs and incoming migration, so that images are always opened inactive first and then get activated.

The interesting point for you could be that opening the image happens immediately when the process starts, but activation would only happen when the VM actually starts running (i.e. on 'cont').

Kevin

#3 lore raw
Quoted 27 lines · Kevin Wolf

Am 30.11.2017 um 15:21 hat Max Reitz geschrieben:

Quoted 10 lines · Vladimir Sementsov-Ogievskiy
Quoted 9 lines

Hi all.

We need the following option: start vm in stopped mode (-S) and write it's disk before start through NBD.
It should be absolutely safe, but unfortunately it is disallowed by root role of the disk.
Is there any workaround or if not, what is a true way to implement this possibility?

Quoted 8 lines
Quoted 4 lines

----
error message:
    unable to execute QEMU command 'nbd-server-add': Conflicts with use
by drive0 as 'root', which does not allow 'write' on #block100

One thing that comes to mind is adding the guest device only after you are done with NBD.

The other of course is to set share-rw=on for the device.

We already allow this with incoming migration, in that case the BlockBackend for the guest device stays inactive and doesn't request permissions yet.

I've been thinking for a while that it would be nice to unify the startup of "normal" VMs and incoming migration, so that images are always opened inactive first and then get activated.

Quoted 5 lines

The interesting point for you could be that opening the image happens immediately when the process starts, but activation would only happen when the VM actually starts running (i.e. on 'cont').

Kevin

Could it be as simple as:

block/block-backend.c +0 -0
index 3064cb888f..b8cbb43f02 100644
@@ -709,7 +709,9 @@ static int blk_do_attach_dev(BlockBackend *blk, void *dev)

     /* While migration is still incoming, we don't need to apply the
      * permissions of guest device BlockBackends. We might still have a block
      * job or NBD server writing to the image for storage migration. */ -    if (runstate_check(RUN_STATE_INMIGRATE)) {
+    if (runstate_check(RUN_STATE_INMIGRATE) ||
+        runstate_check(RUN_STATE_PRELAUNCH))
+    {
         blk->disable_perm = true;
     }

(at least it fixes my case)

Signature · 2 lines
Best regards,
Vladimir