• 一篇关于spice vdagent和利用virtmanager配置spice的文章


    Example using SPICE and QXL for improved Graphics experience in the guest

    This example is based on qemu-kvm (0.15.0) as installed in Fedora 15. Will first show how to do this manually, and second how to do it using the virt-manager tool.

    For extensive details on SPICE, visit http://spice-space.org

    Manually, using qemu-kvm command line directly

    The simplest part is adding the qxl graphics device to the guest. By adding <cdoe>-vga qxl</code>:

    # /usr/bin/qemu-kvm -m 1024 -name f15 -drive file=/images/f15.img,if=virtio -vga qxl

    You'll see a normal SDL window pop up, and if you poke inside the guest you'll find that X is using the qxl device to display:

    $ lspci
    ...
    00:02.0 VGA compatible controller: Red Hat, Inc. Device 0100 (rev 03)
    $ grep QXL /var/log/Xorg.0.log
    [ 15.878] (II) qxl: Driver for QXL virtual graphics: QXL 1

    However, this is not enough to use SPICE. We need to enable the spice server in qemu-kvm. We also need a client to view the guest. So first be sure the client is installed:

    # yum install spice-client

    To keep it simple, we'll not require authentication and simply bind the server to 127.0.0.1 on port 5900.

    # /usr/bin/qemu-kvm -m 1024 -name f15 -drive file=/images/f15.img,if=virtio -vga qxl  -spice port=5900,addr=127.0.0.1,disable-ticketing

    This will not pop up an SDL window, so launch the client to connect to the guest.

    $ spicec -h 127.0.0.1 -p 5900

    We're getting closer. Now the only thing left is to improve the experience by enabling the spice agent communication channel between the host and the guest (you wanted copy and paste between host and guest right? ;)

    This part is a bit arcane. We need to add a virtio-serial device to the guest, and open a port for the spice vdagent. We also need to install the spice vdagent in guest. Be sure the agent is running (and for future, started automatically).

    First the guest side, since the guest is running.

    # yum install spice-vdagent
    # chkconfig --add spice-vdagentd

    Now stop the guest and we'll build up the hostside qemu-kvm commandline. We need to add the virtio-serial device: -device virtio-serial-pci We need to add a port for spice in that device: -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 And we need a spicevmc chardev for that port: -chardev spicevmc,id=spicechannel0,name=vdagent

    It's important that the virserialport chardev= option matches the <cdoe>id=</code> given the chardev (spicechannel0 in this example). It's also important that the port's name= is com.redhat.spice.0, because that's the namespace spice-vdagentd is looking for in the guest. And finally, you need to specify name=vdagent so spice knows what this channel is for.

    So we launch the guest one last time with the complete command line:

    # /usr/bin/qemu-kvm -m 1024 -name f15 -drive file=/images/f15.img,if=virtio -vga qxl -spice port=5900,addr=127.0.0.1,disable-ticketing -device virtio-serial-pci 
                        -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 -chardev spicevmc,id=spicechannel0,name=vdagent

    And kick off a spice client:

    $ spicec -h 127.0.0.1 -p 5900

    Now you can login to the guest, and you'll still see the qxl display device. In addition, you'll see the virtio-serial port:

    $ ls /dev/virtio-ports/
    com.redhat.spice.0

    Now test it out. Grab some text and copy it to the clipboard in the guest. (In gnome-terminal it's Shift-Ctrl-C to copy). And paste it in the host (again, Shift-Ctrl-V to paste in gnome-terminal).

    Enabling SPICE using virt-manager

    This assumes you've already installed a guest with virt-manager or virt-install and it's shut off.

    Start virt-manager, and open your VM by double clicking on it. Click the virtual hardware details (lightbulb).

    First we need to make the Video card a qxl device. Click on Video, and in the Model pulldown, choose, qxl. And Apply.

    Image:Screenshot-video-qxl.png

    Next we need to change the display from VNC to Spice. Click on Display VNC, and in the Type pulldown, choose Spice. And Apply. You'll be prompted to add the Spice agent channels, click Yes. (notice the additional Controller Virtio Serial too).

    Image:Screenshot-display-Spice.png

    Now start the VM. virt-manager has a spice-gtk client built-in. So you don't need to fuss with a manual spice client like you did above. You still need to be sure that the guest has spice-vdagent installed and running. In the guest:

    # yum install spice-vdagent
    # chkconfig --add spice-vdagentd
    # service start spice-vdagentd
    ... log out of X, and log back in, verify agent is running...
    $ ps -ef | grep vdagent
    root 1653 1 0 14:54 ? 00:00:00 /usr/sbin/spice-vdagentd
    gdm 1703 1 0 14:54 ? 00:00:00 /usr/bin/spice-vdagent
    chrisw 1932 1 0 14:55 ? 00:00:00 /usr/bin/spice-vdagent

    And you're done. Test copy and paste and enjoy.

    链接:http://www.linux-kvm.org/page/SPICE

  • 相关阅读:
    JavaScript的数据类型
    伪元素和伪类的区别是什么?
    伪元素::before和::after的详细介绍
    Ksoap2 获取webservice返回值的getResponse() 出现的问题
    解决dropdownlist postback 在 iphone UIwebview 失效的问题
    javascript雪花效果 注释版
    金山词霸每日一句开放平台 .NET demo
    【摘抄】Application.StartupPath和System.Environment.CurrentDirectory的区别
    EditText 监听回车事件 避免2次触发
    【代码】ini 文件读取工具类
  • 原文地址:https://www.cnblogs.com/chinacloud/p/2261370.html
Copyright © 2020-2023  润新知