/* socket_qemu_monitor_clinet.c
* Connect to remote QEMU monitor socket and sending a command to the monitor.
* author: Jay <smile665@gmail.com>
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
int sockfd;
int len;
struct sockaddr_in address;
int result;
char *cmd = "info kvm\n";
char output[200];
/* Create a socket for the client. */
sockfd = socket(AF_INET, SOCK_STREAM, 0);
/* Name the socket, as agreed with the server. */
address.sin_family = AF_INET;
address.sin_addr.s_addr = inet_addr("10.1.77.82");
address.sin_port = htons(4444);
len = sizeof(address);
/* Now connect our socket to the server's socket. */
result = connect(sockfd, (struct sockaddr *)&address, len);
if(result == -1) {
perror("oops: socket connetion failed.");
exit(1);
}
/* We can now read/write via sockfd. */
printf("sending command '%s' to remote qemu monitor\n", cmd);
write(sockfd, cmd, strlen(cmd));
read(sockfd, output, sizeof(output));
printf("output from qemu monitor: %s\n", output);
read(sockfd, output, sizeof(output));
printf("output from qemu monitor: %s\n", output);
close(sockfd);
exit(0);
}
您好,
最近在研究kvm虚拟机迁移。在迁移过程中需要升级qemu,按照网上的方法下载最新版本qemu,然后进行编译、安装。安装成功了,但是发现原来的qemu还存在,libvirt和virsh都使用原来的qemu版本。不知道在哪个地方能修改libvirt条用qemu的地方。之前看到网络一些资料说libvirt会自行检测固定目录,如果存在qemu就是使用它。
新版本:[root@Vm-host5 ~]# /usr/local/bin/qemu-system-x86_64 --version
QEMU emulator version 2.5.0, Copyright (c) 2003-2008 Fabrice Bellard
旧版本:[root@Vm-host5 ~]# /usr/libexec/qemu-kvm --version
QEMU PC emulator version 0.12.1 (qemu-kvm-0.12.1.2-2.479.el6_7.4), Copyright (c) 2003-2008 Fabrice Bellard
也按照网上一做法: 创建一个软连接/usr/local/bin/qemu-system-x86_64 到/usr/libexec/qemu-kvm。创建了软连接,提示说:ln: 创建符号链接 "/usr/libexec/qemu-kvm": 文件已存在。是否我需要删除/usr/libexec/qemu-kvm??不知道有什么方法替换掉原来的qemu?
我是菜鸟,希望您解答我的疑问,感激不尽!
我把/usr/libexec/qemu-kvm删除,然后再把/usr/local/bin/qemu-system-x86_64 连接到/usr/libexec/qemu-kvm去了。我不太能确定这样libvirt是否能调用的我最新版本的qemu。
你这样做也是可以的;不过更加专业的做法是,在guest的xml配置文件中修改 emulator 这个标签行以便指定自己的qemu的位置。
博主您好,我想用qemu-system命令行启动客户机,想要设置virtio网卡驱动的队列对数为2,
命令是这样的:
qemu-system-x86_64 ubuntu.img -smp 4 -m 2048 -net nic,model=virtio -net tap,vhost=on,queues=2
却总提示‘queues’是invalid parameter
问题出在哪里呢
博主您好,我想用qemu-system命令行启动客户机,想要设置virtio网卡驱动的队列对数为2,
命令是这样的:
qemu-system-x86_64 ubuntu.img -smp 4 -m 2048 -net nic,model=virtio -net tap,vhost=on,queues=2
却总提示‘queues’是invalid parameter
可能是你的qemu版本太老了的 升级到2.x之类的试试
另外,这里的配置和你的有所差异,看下:http://www.linux-kvm.org/page/Multiqueue#Enable_MQ_feature