Le jeu. 14 nov. 2024 à 17:00, Frantisek Rysanek <frantisek.rysa...@post.cz>
a écrit :

> > my image `fie.qcow2` is mounted elsewhere (nbd) and running
> > `qemu-system-x86_64 -snapshot -hda file.qcow2` fails with the error
> > "qemu-system-x86_64: -hda usb1.disk: Failed to get shared “write”
> > lock / Is another process using the image [usb1.disk] ?".
>
> Oh...
>
> So you want concurrent access to the block device.
> 1) have it mounted on the host=HV using qemu-nbd
> 2) while at the same time, you want to give it to a guest VM?
>
> Unless you use a filesystem such as GFS2 or OCFS2 inside the
> partitions that exist inside that QCOW2 black box, or mount it
> read-only at both ends, you are asking for trouble :-)
> That is, if QEMU permits unlocked access by a VM, parallel to the
> qemu-nbd loop-mount.
>
> Note that this is just a tangential pointer on my part. Just a start
> of a further journey. Further reading and study.
>
> If you really want concurrent access to a directory tree, consider
> using something like Samba or NFS as the simpler options.
>
> Then again, concurrent access is definitely fun to play with and grow
> :-)
>
> Frank
>
> my problem is exactly this, the link between `device`, `drive` and
`blockdev` : while `device` and `drive` link quite easily, I can't link
`blockdev` to the other two...

setting aside the fact that the image is used elsewhere, my aim is to mimic
`-hda file.qcow2` but without taking the lock into account (`locking=off`).

I currently do this:

```
# qemu-nbd -c /dev/nbd0 file.qcow2
# mount /dev/nbd0p1 /mnt -o uid=me
$ # do some changes in /mnt/...
# umount /mnt
# qemu-nbd -d /dev/nbd0

$ qemu-system-x86_64 -snapshot -hda file.qcow2

# qemu-nbd -c /dev/nbd0 file.qcow2
# mount /dev/nbd0p1 /mnt -o uid=me
$ # do some changes in /mnt/...
# umount /mnt
# qemu-nbd -d /dev/nbd0

$ qemu-system-x86_64 -snapshot -hda file.qcow2

# qemu-nbd -c /dev/nbd0 file.qcow2
# mount /dev/nbd0p1 /mnt -o uid=me
$ # do some changes in /mnt/...
etc...
```

and I'd like to be able to do this :

```
# qemu-nbd -c /dev/nbd0 file.qcow2
# mount /dev/nbd0p1 /mnt -o uid=me
$ # do some changes in /mnt/...

$ qemu-system-x86_64 -snapshot -hda file.qcow2 # with locking=off

$ # do some changes in /mnt/...

$ qemu-system-x86_64 -snapshot -hda file.qcow2 # with locking=off

$ # do some changes in /mnt/...
etc...
```

Reply via email to