提交 820019fc 编写于 作者: P Peter Krempa

qemu: Implement support for EGD backend for virtio-rng

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)
上级 234a5560
...@@ -209,6 +209,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, ...@@ -209,6 +209,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"virtio-rng", "virtio-rng",
"rng-random", /* 130 */ "rng-random", /* 130 */
"rng-egd",
); );
struct _virQEMUCaps { struct _virQEMUCaps {
...@@ -1334,6 +1335,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { ...@@ -1334,6 +1335,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{ "usb-net", QEMU_CAPS_DEVICE_USB_NET}, { "usb-net", QEMU_CAPS_DEVICE_USB_NET},
{ "virtio-rng-pci", QEMU_CAPS_DEVICE_VIRTIO_RNG }, { "virtio-rng-pci", QEMU_CAPS_DEVICE_VIRTIO_RNG },
{ "rng-random", QEMU_CAPS_OBJECT_RNG_RANDOM }, { "rng-random", QEMU_CAPS_OBJECT_RNG_RANDOM },
{ "rng-egd", QEMU_CAPS_OBJECT_RNG_EGD },
}; };
......
...@@ -170,6 +170,7 @@ enum virQEMUCapsFlags { ...@@ -170,6 +170,7 @@ enum virQEMUCapsFlags {
QEMU_CAPS_DEVICE_VIRTIO_RNG = 129, /* virtio-rng device */ QEMU_CAPS_DEVICE_VIRTIO_RNG = 129, /* virtio-rng device */
QEMU_CAPS_OBJECT_RNG_RANDOM = 130, /* the rng-random backend for QEMU_CAPS_OBJECT_RNG_RANDOM = 130, /* the rng-random backend for
virtio rng */ virtio rng */
QEMU_CAPS_OBJECT_RNG_EGD = 131, /* EGD protocol daemon for rng */
QEMU_CAPS_LAST, /* this must always be the last item */ QEMU_CAPS_LAST, /* this must always be the last item */
}; };
......
...@@ -4184,6 +4184,7 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd, ...@@ -4184,6 +4184,7 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
char *backend = NULL;
int ret = -1; int ret = -1;
switch ((enum virDomainRNGBackend) dev->backend) { switch ((enum virDomainRNGBackend) dev->backend) {
...@@ -4204,9 +4205,23 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd, ...@@ -4204,9 +4205,23 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd,
break; break;
case VIR_DOMAIN_RNG_BACKEND_EGD: case VIR_DOMAIN_RNG_BACKEND_EGD:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("egd RNG backend not yet implemented")); if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_RNG_EGD)) {
goto cleanup; 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; break;
case VIR_DOMAIN_RNG_BACKEND_LAST: case VIR_DOMAIN_RNG_BACKEND_LAST:
...@@ -4217,6 +4232,7 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd, ...@@ -4217,6 +4232,7 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd,
cleanup: cleanup:
virBufferFreeAndReset(&buf); virBufferFreeAndReset(&buf);
VIR_FREE(backend);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册