vdagent与server交互

     一、vdagent与server交互

  1. 在server端(qemu/spice)添加VDIPORT设备:

-device virtio-serial-pci, id=virtio-serial0,max_ports=16,bus=pci.0

-chardev spicevmc,name=vdagent,id=vdagent –device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,name=com.redhat.spice.0

 

   2.在guest安装VDIPORT驱动(PCI驱动);

  3.安装vdagent程序。

二、通过vdagent与server交互方式,添加特有功能:

  1. QEMU:

Vi hmp-commands.hx  添加命令执行函数do_spice_command

      格式:

      HXCOMM dirty hack to add qemu monitor command for spice server

      If defined (CONFIG_SPICE)

      {

            .name     =  “spice_command”,

            .args_type  =  “cmd:s,param:s”,

            .params    =   “cmd  param”,

            .help      =   “spice  commands”,

            .user_print  =  “monitor_user_noop”,

            .mhandler.cmd_new =”do_spice_command”,

}

#endif

 

STEXI

ETEXI

     

这样我们就可以通过调用monitor实现我们自定义的命令。

ui/spice-core.c文件中添加函数:

Int do_spice_command(Monitor *mon, const QDict *qdict, QObject **ret_data)

{

 

该函数解析monitor命令,并传递到spice-serverspice_server_command);

  2.spice:

在spice/server下

Vi spice-server.syms

     添加全局函数:spice_server_command

 

SPICE_SERVER_0.10.0{

       Global:

              Monitor_get_agent_msg;

              Spice_server_command;

              Spice_server_playback_set_mute;

              Spice_server_playback_set_volume;

      Spice_server_record_set_mute;

Spice_server_record_set_volume;

Spice_server_get_num_clients;

}SPICE_SERVER_0.8.3;

       

spice.h中声明:

       Int spice_server_command(SpiceServer *s ,const char * command, const char * param, char ** reply);

        

reds.c中定义:

SPICE_gunc_visible int spice_server_command (SpiceServer *s,const char* command, const char * param, char ** reply)

        

从而对命令参数进行解析及判断;

调试相关函数(server/reds.c)

vdagent_admin_msg 

vdagent_guest_admin

vdagent_msg_peek

    vdagent_cmd_msg

 

添加一个命令主要修改:

Qemuqemu/tags/qemu-kvm-1.0/ui/spice-core.c do_spice_command

Spicespice/server/reds.cspice_server_commandvdagent_admin_msgvdagent_msg_peek

Spice-protocolspice/vd_agent.h:在枚举中添加相应命令

 

Enum{

       VD_AGENT_MOUSE_START =1,

VD_AGENT_MONITORS_CONFIG,

VD_AGENT_REPLY,

VD_AGENT_CLIPBOARD,

VD_AGENT_DISPLAY_CONFIG,

VD_AGENT_CLIPBOARD_GRAB,

VD_AGENT_GLIPBOARD_REQUEST,

VD_AGENT_ADMIN,   // subtype of vdagent admin msg

// VD_AGENT_GET_IP // get vm ip

VD_AGENT_GET_NETINFOR, // get ip gw netmask dns ….

}

 

Enum{

       VD_AGENT_ADMIN_SHUTDOWN = 21, // keqisoft

       VD_AGENT_ADMIN_REBOOT,

VD_AGENT_ADMIN_REPORT,

VD_AGENT_ADMIN_DEPLOY,

VD_AGENT_ADMIN_GUESTNAME, // REPORT GUEST NAME TO SPICEC

VD_AGENT_ADMIN_SETPCNAME, // change the computer name

VD_AGENT_ADMIN_SETIP, // change the ip address

VD_AGENT_ADMIN_SETDNS // chang the dns address

VD_AGENT_ADMIN_SETDOMAIN, // join domain or quit domain

VD_AGENT_ADMIN_SETGROUP, // join group or quit group

VD_AGENT_ADMIN_SETRESQLUTION, // add publish message to the VD

VD_AGENT_ADMIN_SETREMOTERESKTOPUSERS, //set remote desktop user

}

第一个枚举是vdagent.c下的函数实现,第二个枚举是在vdadmin.c下函数实现;不要添加错了。

 

vdagent这边添加:

z

1. 若函数在vdagent.c实现,在dispatch_message方法中添加

2. 函数在vdadmin.c实现,在handle_vdagent_admin中添加

 

 

 

 

 

你可能感兴趣的:(JOIN,server,command,cmd,report,playback)