From: Elena Ufimtseva <elena.ufimts...@oracle.com> Add functions to configure remote devices.
Signed-off-by: Elena Ufimtseva <elena.ufimts...@oracle.com> Signed-off-by: John G Johnson <john.g.john...@oracle.com> Signed-off-by: Jagannathan Raman <jag.ra...@oracle.com> --- hw/proxy/qemu-proxy.c | 41 +++++++++++++++++++++++++++++++++++++++-- include/hw/proxy/qemu-proxy.h | 2 ++ include/io/proxy-link.h | 2 ++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index f519beb..9d075ec 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -52,6 +52,7 @@ #include "util/event_notifier-posix.c" #include "hw/i386/pc.h" #include "hw/boards.h" +#include "include/qemu/log.h" /* * TODO: kvm_vm_ioctl is only available for per-target objects (NEED_CPU_H). @@ -61,6 +62,40 @@ int kvm_vm_ioctl(KVMState *s, int type, ...); static void pci_proxy_dev_realize(PCIDevice *dev, Error **errp); +static void setup_irqfd(PCIProxyDev *dev); + +static void proxy_ready(PCIDevice *dev) +{ + PCIProxyDev *pdev = PCI_PROXY_DEV(dev); + + setup_irqfd(pdev); +} + +static void set_remote_opts(PCIDevice *dev, QDict *qdict, unsigned int cmd) +{ + QString *qstr; + ProcMsg msg; + const char *str; + PCIProxyDev *pdev; + + pdev = PCI_PROXY_DEV(dev); + + qstr = qobject_to_json(QOBJECT(qdict)); + str = qstring_get_str(qstr); + qemu_log_mask(LOG_REMOTE_DEBUG, "remote qdict in proxy: %s.\n", str); + + memset(&msg, 0, sizeof(ProcMsg)); + + msg.data2 = (uint8_t *)str; + msg.cmd = cmd; + msg.bytestream = 1; + msg.size = qstring_get_length(qstr) + 1; + msg.num_fds = 0; + + proxy_proc_send(pdev->proxy_link, &msg); + + return; +} static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, int l, unsigned int op) @@ -76,7 +111,8 @@ static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, int l, msg.data2 = (uint8_t *)malloc(sizeof(conf_data)); if (!msg.data2) { - printf("Failed to allocate memory for msg.data2."); + qemu_log_mask(LOG_REMOTE_DEBUG, "Failed to allocate memory" + " for msg.data2.\n"); return -ENOMEM; } @@ -268,8 +304,9 @@ static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) dev->sync = REMOTE_MEM_SYNC(object_new(TYPE_MEMORY_LISTENER)); configure_memory_sync(dev->sync, dev->proxy_link); + dev->set_remote_opts = set_remote_opts; + dev->proxy_ready = proxy_ready; - setup_irqfd(dev); } static void send_bar_access_msg(ProxyLinkState *proxy_link, MemoryRegion *mr, diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index 55160b0..6b61bb7 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -28,6 +28,8 @@ #include "io/proxy-link.h" #include "hw/proxy/memory-sync.h" #include "qemu/event_notifier.h" +#include "hw/pci/pci.h" +#include "block/qdict.h" #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index ce2fcc3..21d63cc 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -72,6 +72,8 @@ typedef enum { BAR_WRITE, BAR_READ, SET_IRQFD, + DEV_OPTS, + DRIVE_OPTS, DEVICE_ADD, DEVICE_DEL, MAX, -- 1.8.3.1