From 5436fc9752adbef67bf358e2b41d627af744ce2c Mon Sep 17 00:00:00 2001 From: oleina Date: Sat, 19 Oct 2024 16:25:28 -0700 Subject: [PATCH 1/2] added configuration for domain.devices.interface vhostuser source: https://libvirt.org/formatdomain.html#vhost-user-interface also added tests, let me know if they're in the right place. --- checks/domain/issues/expected.xml | 7 +++++++ checks/domain/issues/input.nix | 17 +++++++++++++++-- generate-xml/domain.nix | 10 ++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/checks/domain/issues/expected.xml b/checks/domain/issues/expected.xml index 86e106a..e343948 100644 --- a/checks/domain/issues/expected.xml +++ b/checks/domain/issues/expected.xml @@ -3,4 +3,11 @@ test + + + + + + + diff --git a/checks/domain/issues/input.nix b/checks/domain/issues/input.nix index 36ce085..3f6edec 100644 --- a/checks/domain/issues/input.nix +++ b/checks/domain/issues/input.nix @@ -1,5 +1,18 @@ -{ ... }: -{ +{ ... }: { name = "issues"; cpu.model.name = "test"; # ISSUE #66 + devices.interface = [ + { + type = "vhostuser"; + source = { + type = "unix"; + path = "/tmp/vhost.sock"; + mode = "client"; + reconnect = { + enabled = true; + timeout = 10; + }; + }; + } + ]; } diff --git a/generate-xml/domain.nix b/generate-xml/domain.nix index a0ec711..2f40e57 100644 --- a/generate-xml/domain.nix +++ b/generate-xml/domain.nix @@ -400,8 +400,14 @@ let (subattr "dev" typeString) (subattr "mode" typeString) (subattr "network" typeString) - ] [ addresselem ]) - (subelem "model" [ (subattr "type" typeString) ] [ ]) + (subattr "type" typeString) + # this typically points to a socket (/tmp/my.sock), so don't use typePath, which only allows in-store elements. + (subattr "path" typeString) + ] [ + addresselem + (subelem "reconnect" [ (subattr "enabled" typeBoolYesNo) (subattr "timeout" typeInt) ] [ ]) + ]) + (subelem "model" [ (subattr "type" typeString) ] [ ]) targetelem addresselem ]) From 2fd943fa34b658b4e2aafb308566e7c94e4d2f18 Mon Sep 17 00:00:00 2001 From: oleina Date: Sat, 19 Oct 2024 18:46:57 -0700 Subject: [PATCH 2/2] added opts for NIC --- checks/domain/issues/expected.xml | 6 ++++++ checks/domain/issues/input.nix | 29 +++++++++++++++++++++++++++++ generate-xml/domain.nix | 31 ++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/checks/domain/issues/expected.xml b/checks/domain/issues/expected.xml index e343948..9f22b2a 100644 --- a/checks/domain/issues/expected.xml +++ b/checks/domain/issues/expected.xml @@ -9,5 +9,11 @@ + + + + + + diff --git a/checks/domain/issues/input.nix b/checks/domain/issues/input.nix index 3f6edec..93e82c7 100644 --- a/checks/domain/issues/input.nix +++ b/checks/domain/issues/input.nix @@ -14,5 +14,34 @@ }; }; } + { + type = "network"; + driver = { + name = "vhost"; + txmode = "iothread"; + mode = "client"; + ioeventfd = true; + event_idx = false; + queues = 5; + rx_queue_size = 256; + tx_queue_size = 256; + host = { + csum = false; + gso = false; + tso4 = false; + tso6 = false; + ecn = false; + ufo = false; + mrg_rxbuf = false; + }; + guest = { + csum = false; + tso4 = false; + tso6 = false; + ecn = false; + ufo = false; + }; + }; + } ]; } diff --git a/generate-xml/domain.nix b/generate-xml/domain.nix index 2f40e57..98b53e4 100644 --- a/generate-xml/domain.nix +++ b/generate-xml/domain.nix @@ -393,6 +393,35 @@ let (subattr "trustGuestRxFilters" typeBoolYesNo) ] [ + (subelem "driver" [ + (subattr "name" typeString) + (subattr "txmode" typeString) + (subattr "ioeventfd" typeBoolOnOff) + (subattr "event_idx" typeBoolOnOff) + (subattr "queues" typeInt) + (subattr "rx_queue_size" typeInt) + (subattr "tx_queue_size" typeInt) + ] + ( + let + nicOpts = [ + (subattr "csum" typeBoolOnOff) + (subattr "tso4" typeBoolOnOff) + (subattr "tso6" typeBoolOnOff) + (subattr "ecn" typeBoolOnOff) + (subattr "ufo" typeBoolOnOff) + ]; + + nicHostOpts = [ + (subattr "gso" typeBoolOnOff) + (subattr "mrg_rxbuf" typeBoolOnOff) + ]; + in + [ + (subelem "host" (nicHostOpts ++ nicOpts) [ ]) + (subelem "guest" nicOpts [ ]) + ] + )) (subelem "mac" [ (subattr "address" typeString) ] [ ]) (subelem "source" [ @@ -407,7 +436,7 @@ let addresselem (subelem "reconnect" [ (subattr "enabled" typeBoolYesNo) (subattr "timeout" typeInt) ] [ ]) ]) - (subelem "model" [ (subattr "type" typeString) ] [ ]) + (subelem "model" [ (subattr "type" typeString) ] [ ]) targetelem addresselem ])