qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] migrate to fd - how to use with HMP?
Date: Fri, 28 Feb 2014 15:05:12 +1100	[thread overview]
Message-ID: <53100AF8.8080409@ozlabs.ru> (raw)

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

             reply	other threads:[~2014-02-28  4:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28  4:05 Alexey Kardashevskiy [this message]
2014-02-28 10:27 ` [Qemu-devel] migrate to fd - how to use with HMP? Stefan Hajnoczi
2014-02-28 10:30   ` Alexey Kardashevskiy
2014-02-28 16:55     ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53100AF8.8080409@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).