qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] migrate to fd - how to use with HMP?


From: Alexey Kardashevskiy
Subject: [Qemu-devel] migrate to fd - how to use with HMP?
Date: Fri, 28 Feb 2014 15:05:12 +1100
User-agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

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 via email to

[Prev in Thread] Current Thread [Next in Thread]