qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] migrate to fd - how to use with HMP?
@ 2014-02-28  4:05 Alexey Kardashevskiy
  2014-02-28 10:27 ` Stefan Hajnoczi
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Kardashevskiy @ 2014-02-28  4:05 UTC (permalink / raw)
  To: qemu-devel@nongnu.org; +Cc: Stefan Hajnoczi

Hi!

libvirt uses live migration to fd. I got some bugreports recently and
decided to try it without libvirt. So I opened HMP and found "getfd"
command. Then with the help of Stefan I tried to use it. And failed.

I run QEMU as this:
/home/aik/qemu-system-ppc64 \
	-enable-kvm \
	-m 1024 \
	-L /home/aik/qemu-ppc64-bios/ \
	-machine pseries \
	-trace events=/home/aik/qemu_trace_events \
	-initrd 1.cpio \
	-kernel vml313 \
	-nographic \
	-vga none \
	-S \
	-chardev socket,id=mon,path=/home/aik/qemu.monitor,server,nowait \
	-mon chardev=mon,mode=readline \
	-chardev socket,id=mon1,host=localhost,port=10000,server,nowait \
	-mon chardev=mon1,mode=readline \
	-chardev stdio,id=id0,signal=off \
	-device spapr-vty,id=id1,chardev=id0,reg=0x71000100


Here is a python3 script I use for QEMU:

qemu = subprocess.Popen(qq, shell=True)
time.sleep(2)
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect("/home/aik/qemu.monitor")
scm_cmd = "/home/aik/socket_scm_helper " + str(sock.fileno()) + "
/home/aik/test1"
p = subprocess.Popen(scm_cmd.split(), close_fds = False)
p.wait()
sock.close()
add_fd()
qemu.wait()


I checked that without this socket_scm_helper magic both monitors work fine
("telnet localhost 10000" and "socat UNIX-CONNECT:./qemu.monitor STDIN"
both give working HMP).

As I see from traces, unix_process_msgfd() receives request and saves fd.

However once socket_scm_helper talked to "mon" (./qemu.monitor), I cannot
get any response from it via "socat UNIX-CONNECT:./qemu.monitor STDIN".

And "getfd" command sent to "mon1" responds with "No file descriptor
supplied via SCM_RIGHTS" which is true - the fd belongs to "mon".

I tried IO test 042 and that passes. I looked at
tests/qemu-iotests/socket_scm_helper.c and I did not find where it actually
tries to do anything with the passed file fd. Very confusing.


And here I got stuck. How is it supposed to work? Thanks!



diff --git a/tests/qemu-iotests-quick.sh b/tests/qemu-iotests-quick.sh
index cf90de0..91e994c 100755
--- a/tests/qemu-iotests-quick.sh
+++ b/tests/qemu-iotests-quick.sh
@@ -12,6 +12,6 @@ export QEMU_IO_PROG="$(pwd)/qemu-io"
 cd $SRC_PATH/tests/qemu-iotests

 ret=0
-./check -T -nocache -qcow2 -g quick || ret=1
+./check -T -nocache -raw -g aik || ret=1

 exit $ret
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index cc750c9..f57f6bb 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -51,7 +51,7 @@
 042 rw auto quick
 043 rw auto backing
 044 rw auto
-045 rw auto
+045 rw auto aik
 046 rw auto aio
 047 rw auto
 048 img auto quick
diff --git a/tests/qemu-iotests/socket_scm_helper.c
b/tests/qemu-iotests/socket_scm_helper.c
index 0e2b285..8195983 100644
--- a/tests/qemu-iotests/socket_scm_helper.c
+++ b/tests/qemu-iotests/socket_scm_helper.c
@@ -52,7 +52,7 @@ static int send_fd(int fd, int fd_to_send)
     cmsg->cmsg_len = CMSG_LEN(sizeof(int));
     cmsg->cmsg_level = SOL_SOCKET;
     cmsg->cmsg_type = SCM_RIGHTS;
-    memcpy(CMSG_DATA(cmsg), &fd, sizeof(int));
+    memcpy(CMSG_DATA(cmsg), &fd_to_send, sizeof(int));

     do {
         ret = sendmsg(fd, &msg, 0);




-- 
Alexey

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] migrate to fd - how to use with HMP?
  2014-02-28  4:05 [Qemu-devel] migrate to fd - how to use with HMP? Alexey Kardashevskiy
@ 2014-02-28 10:27 ` Stefan Hajnoczi
  2014-02-28 10:30   ` Alexey Kardashevskiy
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-02-28 10:27 UTC (permalink / raw)
  To: Alexey Kardashevskiy; +Cc: qemu-devel@nongnu.org

On Fri, Feb 28, 2014 at 03:05:12PM +1100, Alexey Kardashevskiy wrote:
> However once socket_scm_helper talked to "mon" (./qemu.monitor), I cannot
> get any response from it via "socat UNIX-CONNECT:./qemu.monitor STDIN".

Have you tried with QMP?  Perhaps the HMP monitor handles
connect/disconnect differently from the QMP monitor.

I guess this will require more step-by-step debugging of monitor.c to
find out what's going on.

Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] migrate to fd - how to use with HMP?
  2014-02-28 10:27 ` Stefan Hajnoczi
@ 2014-02-28 10:30   ` Alexey Kardashevskiy
  2014-02-28 16:55     ` Stefan Hajnoczi
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Kardashevskiy @ 2014-02-28 10:30 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel@nongnu.org

On 02/28/2014 09:27 PM, Stefan Hajnoczi wrote:
> On Fri, Feb 28, 2014 at 03:05:12PM +1100, Alexey Kardashevskiy wrote:
>> However once socket_scm_helper talked to "mon" (./qemu.monitor), I cannot
>> get any response from it via "socat UNIX-CONNECT:./qemu.monitor STDIN".
> 
> Have you tried with QMP?  Perhaps the HMP monitor handles
> connect/disconnect differently from the QMP monitor.
> 
> I guess this will require more step-by-step debugging of monitor.c to
> find out what's going on.


One of my questions is still unanswered :) Is socket_scm_helper assumed to
be correct or it is a bug? Because if it is correct, I do not know what to
think. Thanks.


diff --git a/tests/qemu-iotests/socket_scm_helper.c
b/tests/qemu-iotests/socket_scm_helper.c
index 0e2b285..8195983 100644
--- a/tests/qemu-iotests/socket_scm_helper.c
+++ b/tests/qemu-iotests/socket_scm_helper.c
@@ -52,7 +52,7 @@ static int send_fd(int fd, int fd_to_send)
     cmsg->cmsg_len = CMSG_LEN(sizeof(int));
     cmsg->cmsg_level = SOL_SOCKET;
     cmsg->cmsg_type = SCM_RIGHTS;
-    memcpy(CMSG_DATA(cmsg), &fd, sizeof(int));
+    memcpy(CMSG_DATA(cmsg), &fd_to_send, sizeof(int));



-- 
Alexey

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] migrate to fd - how to use with HMP?
  2014-02-28 10:30   ` Alexey Kardashevskiy
@ 2014-02-28 16:55     ` Stefan Hajnoczi
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-02-28 16:55 UTC (permalink / raw)
  To: Alexey Kardashevskiy; +Cc: qemu-devel@nongnu.org

On Fri, Feb 28, 2014 at 09:30:33PM +1100, Alexey Kardashevskiy wrote:
> On 02/28/2014 09:27 PM, Stefan Hajnoczi wrote:
> > On Fri, Feb 28, 2014 at 03:05:12PM +1100, Alexey Kardashevskiy wrote:
> >> However once socket_scm_helper talked to "mon" (./qemu.monitor), I cannot
> >> get any response from it via "socat UNIX-CONNECT:./qemu.monitor STDIN".
> > 
> > Have you tried with QMP?  Perhaps the HMP monitor handles
> > connect/disconnect differently from the QMP monitor.
> > 
> > I guess this will require more step-by-step debugging of monitor.c to
> > find out what's going on.
> 
> 
> One of my questions is still unanswered :) Is socket_scm_helper assumed to
> be correct or it is a bug? Because if it is correct, I do not know what to
> think. Thanks.
> 
> 
> diff --git a/tests/qemu-iotests/socket_scm_helper.c
> b/tests/qemu-iotests/socket_scm_helper.c
> index 0e2b285..8195983 100644
> --- a/tests/qemu-iotests/socket_scm_helper.c
> +++ b/tests/qemu-iotests/socket_scm_helper.c
> @@ -52,7 +52,7 @@ static int send_fd(int fd, int fd_to_send)
>      cmsg->cmsg_len = CMSG_LEN(sizeof(int));
>      cmsg->cmsg_level = SOL_SOCKET;
>      cmsg->cmsg_type = SCM_RIGHTS;
> -    memcpy(CMSG_DATA(cmsg), &fd, sizeof(int));
> +    memcpy(CMSG_DATA(cmsg), &fd_to_send, sizeof(int));

Don't assume the 045 test or socket_scm_helper is correct.  Your patch
makes sense.  Please post it to qemu-devel.

Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-28 16:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-28  4:05 [Qemu-devel] migrate to fd - how to use with HMP? Alexey Kardashevskiy
2014-02-28 10:27 ` Stefan Hajnoczi
2014-02-28 10:30   ` Alexey Kardashevskiy
2014-02-28 16:55     ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).