This patch adds a new capability bit QEMU_CAPS_OBJECT_RNG_EGD and code to support the egd backend for the VirtIO RNG device. The device is added by 3 qemu command line options: -chardev socket,id=charrng0,host=1.2.3.4,port=1234 (communication backend) -object rng-egd,chardev=charrng0,id=rng0 (RNG protocol client) -device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x4 (the RNG device) --- Notes: Version 2: - ACKed, no change, doesn't make sense to push alone src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 22 +++++++++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a3d9e06..02ce4bd 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -207,6 +207,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "add-fd", "virtio-rng", "rng-random", + + "rng-egd", /* 130 */ ); struct _virQEMUCaps { @@ -1332,6 +1334,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "usb-net", QEMU_CAPS_DEVICE_USB_NET}, { "virtio-rng-pci", QEMU_CAPS_DEVICE_VIRTIO_RNG }, { "rng-random", QEMU_CAPS_OBJECT_RNG_RANDOM }, + { "rng-egd", QEMU_CAPS_OBJECT_RNG_EGD }, }; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index ee0d0ca..53dbcac 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -169,6 +169,7 @@ enum virQEMUCapsFlags { QEMU_CAPS_DEVICE_VIRTIO_RNG = 128, /* virtio-rng device */ QEMU_CAPS_OBJECT_RNG_RANDOM = 129, /* the rng-random backend for virtio rng */ + QEMU_CAPS_OBJECT_RNG_EGD = 130, /* EGD protocol daemon for rng */ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4a51413..1c9bfc9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4184,6 +4184,7 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; + char *backend = NULL; int ret = -1; switch ((enum virDomainRNGBackend) dev->backend) { @@ -4204,9 +4205,23 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd, break; case VIR_DOMAIN_RNG_BACKEND_EGD: - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("egd RNG backend not yet implemented")); - goto cleanup; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_RNG_EGD)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("this qemu doesn't support the rng-egd " + "backend")); + goto cleanup; + } + + if (!(backend = qemuBuildChrChardevStr(dev->source.chardev, + dev->info.alias, qemuCaps))) + goto cleanup; + + virCommandAddArgList(cmd, "-chardev", backend, NULL); + + virCommandAddArg(cmd, "-object"); + virCommandAddArgFormat(cmd, "rng-egd,chardev=char%s,id=%s", + dev->info.alias, dev->info.alias); break; case VIR_DOMAIN_RNG_BACKEND_LAST: @@ -4217,6 +4232,7 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd, cleanup: virBufferFreeAndReset(&buf); + VIR_FREE(backend); return ret; } -- 1.8.1.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list