Skip to contentSkip to conversation

add text about how to use qemu-nbd with qemu

PATCH In review [email protected] 5 participants 16 messages Jul 3, 2012 – Jul 9, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add text about how to use qemu-nbd with qemu

From: Wenchao Xia <[email protected]>

Qemu system emulator reports only fails that make people confused
about why, when it is invoked with nbd block device tring to connect qemu-nbd server. In fact qemu will try connect server for several times but server only accept one connect by default.
I paid some times to find out why it fails. This patch add special
text to explain how to use it in such case.

---
 qemu-nbd.texi |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
qemu-nbd.texi +6 -0
index 6955d90..014040a 100644
@@ -44,6 +44,12 @@ Export QEMU disk image using NBD protocol.
   display this help and exit
 @item -V, --version
   output version information and exit
+
+  Note: When qemu-nbd was used to export a disk that would be used by QEMU
+block device, -t or --persistent must be set for that QEMU nbd client would try
+connect more than one time. For eg:
+  qemu-nbd ./simple.img -p 10809 -t
+  qemu -hdb nbd:127.0.0.1:10809
 @end table
 
 @c man end
Signature · 1 line
1.7.1
#1 lore raw

Il 03/07/2012 13:05, [email protected] ha scritto:

qemu-nbd.texi Export QEMU disk image using NBD protocol. · line 52

Quoted 6 lines
qemu-nbd.texi +6 -0
+
+  Note: When qemu-nbd was used to export a disk that would be used by QEMU
+block device, -t or --persistent must be set for that QEMU nbd client would try
+connect more than one time. For eg:
+  qemu-nbd ./simple.img -p 10809 -t
+  qemu -hdb nbd:127.0.0.1:10809

We could actually make persistent the default unless we're using qemu-nbd in client mode (i.e. exporting to /dev/nbd*), and drop the option. What do you think?

Paolo

author
#2 lore raw
Quoted 12 lines · Paolo Bonzini

Il 03/07/2012 13:05, [email protected] ha scritto:

qemu-nbd.texi Export QEMU disk image using NBD protocol. · line 52

Quoted 6 lines
qemu-nbd.texi +6 -0
+
+  Note: When qemu-nbd was used to export a disk that would be used by QEMU
+block device, -t or --persistent must be set for that QEMU nbd client would try
+connect more than one time. For eg:
+  qemu-nbd ./simple.img -p 10809 -t
+  qemu -hdb nbd:127.0.0.1:10809

We could actually make persistent the default unless we're using qemu-nbd in client mode (i.e. exporting to /dev/nbd*), and drop the option. What do you think?

I think there will be no harm to make persistent default, but mark
this change in document in case of breaking potential user case.(maybe someone have used qemu and expect qemu-nbd exit in script).

Quoted 2 lines

Paolo

Signature · 5 lines
Best Regards

Wayne Xia
mail:[email protected]
tel:86-010-82450803
author
#3 lore raw
In reply to Paolo Bonzini
Quoted 12 lines · Paolo Bonzini

Il 03/07/2012 13:05, [email protected] ha scritto:

qemu-nbd.texi Export QEMU disk image using NBD protocol. · line 52

Quoted 6 lines
qemu-nbd.texi +6 -0
+
+  Note: When qemu-nbd was used to export a disk that would be used by QEMU
+block device, -t or --persistent must be set for that QEMU nbd client would try
+connect more than one time. For eg:
+  qemu-nbd ./simple.img -p 10809 -t
+  qemu -hdb nbd:127.0.0.1:10809

We could actually make persistent the default unless we're using qemu-nbd in client mode (i.e. exporting to /dev/nbd*), and drop the option. What do you think?

Quoted 2 lines

Paolo

Hi Paolo, should I make a patch to make persistent the default for qemu-nbd?

Signature · 5 lines
Best Regards

Wayne Xia
mail:[email protected]
tel:86-010-82450803
#4 lore raw

Il 05/07/2012 05:29, Wayne Xia ha scritto:

Quoted 14 lines
Quoted 14 lines

qemu-nbd.texi Export QEMU disk image using NBD protocol. · line 52

Quoted 9 lines
(quoted diff) +2 -0
+
+  Note: When qemu-nbd was used to export a disk that would be used

by QEMU
+block device, -t or --persistent must be set for that QEMU nbd client would try

qemu-nbd.texi +3 -0
+connect more than one time. For eg:
+  qemu-nbd ./simple.img -p 10809 -t
+  qemu -hdb nbd:127.0.0.1:10809

We could actually make persistent the default unless we're using qemu-nbd in client mode (i.e. exporting to /dev/nbd*), and drop the option. What do you think?

Quoted 4 lines
Quoted 2 lines

Paolo

Hi Paolo, should I make a patch to make persistent the default for qemu-nbd?

Yes, why not. However, as mentioned above client mode should still be non-persistent.

Paolo

#5 lore raw
Quoted 1 line · Paolo Bonzini

Il 05/07/2012 05:29, Wayne Xia ha scritto:

[]

Quoted 5 lines
Quoted 2 lines

Hi Paolo, should I make a patch to make persistent the default for qemu-nbd?

Yes, why not. However, as mentioned above client mode should still be non-persistent.

I don't think this makes sense or is good: now we'll need to have an option to enable non-persistent mode, and have to fix scripts which expects non-persistent mode by default (does autotest uses it?).

Instead, it is more productive and rigth (IMHO anyway) to fix the qemu side to stop connecting two times for one device.

thanks,

/mjt

#6 lore raw

Il 05/07/2012 10:13, Michael Tokarev ha scritto:

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Hi Paolo, should I make a patch to make persistent the default for qemu-nbd?

Yes, why not. However, as mentioned above client mode should still be non-persistent.

I don't think this makes sense or is good: now we'll need to have an option to enable non-persistent mode, and have to fix scripts which expects non-persistent mode by default (does autotest uses it?).

Hmm, yeah, with daemon mode non-persistent is still better. I guess it is just a bogus thing we have to live with, just like daemon mode itself.

Quoted 3 lines

Instead, it is more productive and rigth (IMHO anyway) to fix the qemu side to stop connecting two times for one device.

That too.

Paolo

author
#7 lore raw
Quoted 6 lines · Paolo Bonzini

Il 05/07/2012 10:13, Michael Tokarev ha scritto:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Hi Paolo, should I make a patch to make persistent the default for qemu-nbd?

Yes, why not. However, as mentioned above client mode should still be non-persistent.

Quoted 8 lines
Quoted 4 lines

I don't think this makes sense or is good: now we'll need to have an option to enable non-persistent mode, and have to fix scripts which expects non-persistent mode by default (does autotest uses it?).

Hmm, yeah, with daemon mode non-persistent is still better. I guess it is just a bogus thing we have to live with, just like daemon mode itself.

From the product perspective, keeping qemu-nbd option unchanged seems
better. I think changing the qemu block behavior needs extra efforts and not so worthy. Actually I don't think this is a bug, the nbd-block still works but just need some document to avoid making user debug it. Maybe a document is the easiest way.

Quoted 8 lines
Quoted 3 lines

Instead, it is more productive and rigth (IMHO anyway) to fix the qemu side to stop connecting two times for one device.

That too.

Paolo

Signature · 5 lines
Best Regards

Wayne Xia
mail:[email protected]
tel:86-010-82450803
author
#8 lore raw

Paolo, what do you think write a short section in document for it, but
make no change to code?

Quoted 31 lines
Quoted 6 lines · Paolo Bonzini

Il 05/07/2012 10:13, Michael Tokarev ha scritto:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Hi Paolo, should I make a patch to make persistent the default for qemu-nbd?

Yes, why not. However, as mentioned above client mode should still be non-persistent.

Quoted 8 lines
Quoted 4 lines

I don't think this makes sense or is good: now we'll need to have an option to enable non-persistent mode, and have to fix scripts which expects non-persistent mode by default (does autotest uses it?).

Hmm, yeah, with daemon mode non-persistent is still better. I guess it is just a bogus thing we have to live with, just like daemon mode itself.

From the product perspective, keeping qemu-nbd option unchanged seems
better. I think changing the qemu block behavior needs extra efforts and not so worthy. Actually I don't think this is a bug, the nbd-block still works but just need some document to avoid making user debug it. Maybe a document is the easiest way.

Quoted 8 lines
Quoted 3 lines

Instead, it is more productive and rigth (IMHO anyway) to fix the qemu side to stop connecting two times for one device.

That too.

Paolo

Signature · 5 lines
Best Regards

Wayne Xia
mail:[email protected]
tel:86-010-82450803
#9 lore raw

Il 09/07/2012 09:11, Wayne Xia ha scritto:

Quoted 2 lines

Paolo, what do you think write a short section in document for it, but
make no change to code?

That's okay, but perhaps for 1.2 we can fix the probing. I'll apply the patch to nbd-next and not submit it until it's clear that 1.2 will still have the bug.

Paolo

#10 lore raw
In reply to [email protected]

qemu-nbd.texi Export QEMU disk image using NBD protocol. · line 50

Quoted 4 lines
qemu-nbd.texi +4 -0
+
+  Note: When qemu-nbd was used to export a disk that would be used by QEMU
+block device, -t or --persistent must be set for that QEMU nbd client would try
+connect more than one time. For eg:
                               ^^^^^^

Not a native english speaker, but I never see such usage before.
Should be "For example"?

Regards,
chenwj

Signature · 5 lines
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
author
#11 lore raw
Quoted 8 lines · 陳韋任 (Wei-Ren Chen)

qemu-nbd.texi Export QEMU disk image using NBD protocol. · line 50

Quoted 4 lines
qemu-nbd.texi +4 -0
+
+  Note: When qemu-nbd was used to export a disk that would be used by QEMU
+block device, -t or --persistent must be set for that QEMU nbd client would try
+connect more than one time. For eg:
                                ^^^^^^

Not a native english speaker, but I never see such usage before.
Should be "For example"?

Sorry it should be "i.e." or "for example", my bad spell custom.

Quoted 3 lines

Regards,
chenwj

Signature · 5 lines
Best Regards

Wayne Xia
mail:[email protected]
tel:86-010-82450803
#12 lore raw
In reply to [email protected]
Quoted 19 lines · On 03.07.2012 15:05, [email protected] wrote:

From: Wenchao Xia <[email protected]>

Qemu system emulator reports only fails that make people confused
about why, when it is invoked with nbd block device tring to connect qemu-nbd server. In fact qemu will try connect server for several times but server only accept one connect by default.
I paid some times to find out why it fails. This patch add special
text to explain how to use it in such case.

---
 qemu-nbd.texi |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
qemu-nbd.texi +0 -0
index 6955d90..014040a 100644

qemu-nbd.texi Export QEMU disk image using NBD protocol. · line 52

Quoted 9 lines
qemu-nbd.texi +6 -0
@@ -44,6 +44,12 @@ Export QEMU disk image using NBD protocol.
   display this help and exit
 @item -V, --version
   output version information and exit
+
+  Note: When qemu-nbd was used to export a disk that would be used by QEMU
+block device, -t or --persistent must be set for that QEMU nbd client would try
+connect more than one time. For eg:
+  qemu-nbd ./simple.img -p 10809 -t
+  qemu -hdb nbd:127.0.0.1:10809

It is not accurate.

qemu connect to nbd server not "several" but exactly two times by default. The first connection it does (it need not be a separate connection actually, and this, I'd say, a bug in qemu) in order to guess the format of the internal structure inside - be it raw, or qcow, or anything else. So, if you specify the format of the device explicitly, by using format=raw, only single connection will be made.

/mjt

author
#13 lore raw
Quoted 32 lines · On 03.07.2012 15:05, [email protected] wrote:
Quoted 19 lines

From: Wenchao Xia<[email protected]>

Qemu system emulator reports only fails that make people confused
about why, when it is invoked with nbd block device tring to connect qemu-nbd server. In fact qemu will try connect server for several times but server only accept one connect by default.
I paid some times to find out why it fails. This patch add special
text to explain how to use it in such case.

---
  qemu-nbd.texi |    6 ++++++
  1 files changed, 6 insertions(+), 0 deletions(-)
qemu-nbd.texi +0 -0
index 6955d90..014040a 100644

qemu-nbd.texi Export QEMU disk image using NBD protocol. · line 52

Quoted 9 lines
qemu-nbd.texi +6 -0
@@ -44,6 +44,12 @@ Export QEMU disk image using NBD protocol.
    display this help and exit
  @item -V, --version
    output version information and exit
+
+  Note: When qemu-nbd was used to export a disk that would be used by QEMU
+block device, -t or --persistent must be set for that QEMU nbd client would try
+connect more than one time. For eg:
+  qemu-nbd ./simple.img -p 10809 -t
+  qemu -hdb nbd:127.0.0.1:10809

It is not accurate.

Quoted 3 lines

qemu connect to nbd server not "several" but exactly two times by default. The first connection it does (it need not be a separate connection actually, and this, I'd say, a bug in qemu) in order to guess the format

I think so, actually I planned to patch qemu client side to make it
connect only once, but the disconnect logical lies in general block layer and changing of that may break other block device logical I guess, so I gave up of that approach.

Quoted 3 lines

of the internal structure inside - be it raw, or qcow, or anything else. So, if you specify the format of the device explicitly, by using format=raw, only single connection will be made.

thanks, that helped me. A bit more question: is there a way to let
nbd client know the image format used by server? qemu-nbd exports simple_qcow2.img, and qemu saw it as raw block device, is it possible to get the information in qemu that server is using qcow2 image?

Quoted 3 lines

/mjt

Signature · 5 lines
Best Regards

Wayne Xia
mail:[email protected]
tel:86-010-82450803
#14 lore raw

Il 04/07/2012 04:14, Wayne Xia ha scritto:

Quoted 8 lines
Quoted 4 lines

of the internal structure inside - be it raw, or qcow, or anything else. So, if you specify the format of the device explicitly, by using format=raw, only single connection will be made.

thanks, that helped me. A bit more question: is there a way to let
nbd client know the image format used by server? qemu-nbd exports simple_qcow2.img, and qemu saw it as raw block device, is it possible to get the information in qemu that server is using qcow2 image?

qemu-nbd takes care of the format translation itself, and always exposes the image as raw.

Paolo

#15 lore raw
In reply to Michael Tokarev

Am 03.07.2012 21:45, schrieb Michael Tokarev:

Quoted 32 lines · On 03.07.2012 15:05, [email protected] wrote:
Quoted 19 lines

From: Wenchao Xia <[email protected]>

Qemu system emulator reports only fails that make people confused
about why, when it is invoked with nbd block device tring to connect qemu-nbd server. In fact qemu will try connect server for several times but server only accept one connect by default.
I paid some times to find out why it fails. This patch add special
text to explain how to use it in such case.

---
 qemu-nbd.texi |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
qemu-nbd.texi +0 -0
index 6955d90..014040a 100644

qemu-nbd.texi Export QEMU disk image using NBD protocol. · line 52

Quoted 9 lines
qemu-nbd.texi +6 -0
@@ -44,6 +44,12 @@ Export QEMU disk image using NBD protocol.
   display this help and exit
 @item -V, --version
   output version information and exit
+
+  Note: When qemu-nbd was used to export a disk that would be used by QEMU
+block device, -t or --persistent must be set for that QEMU nbd client would try
+connect more than one time. For eg:
+  qemu-nbd ./simple.img -p 10809 -t
+  qemu -hdb nbd:127.0.0.1:10809

It is not accurate.

Quoted 4 lines

qemu connect to nbd server not "several" but exactly two times by default. The first connection it does (it need not be a separate connection actually, and this, I'd say, a bug in qemu) in order to guess the format of the internal structure inside - be it raw, or qcow, or anything else.

I think I agree that we should get rid of this behaviour. It's going to bite us with fd passing as well. It should be possible to open the protocol first and the use that open BlockDriverState both for probing and for the real open.

Kevin