From: moddingfox via pve-devel <pve-devel@lists.proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: moddingfox <moddingfox@gmail.com>, Tyst Marin <moddingfox@foxtek.us>
Subject: [pve-devel] [PATCH container 1/1] Optional mapped devices at vm boot
Date: Tue, 26 Nov 2024 01:51:57 +0000 [thread overview]
Message-ID: <mailman.693.1732617417.391.pve-devel@lists.proxmox.com> (raw)
In-Reply-To: <20241126015157.1107116-1-moddingfox@foxtek.us>
[-- Attachment #1: Type: message/rfc822, Size: 7589 bytes --]
From: moddingfox <moddingfox@gmail.com>
To: pve-devel@lists.proxmox.com
Cc: Tyst Marin <moddingfox@foxtek.us>
Subject: [PATCH container 1/1] Optional mapped devices at vm boot
Date: Tue, 26 Nov 2024 01:51:57 +0000
Message-ID: <20241126015157.1107116-2-moddingfox@foxtek.us>
From: Tyst Marin <moddingfox@foxtek.us>
This change intends to add support for optional mapped usb devices.
Currently if a mapped device is unplugged vm boot will fail, tihs will provide an option to ignore specified missing devices.
This keeps the default behavior while allowing for optional devices to be specified.
---
PVE/QemuServer/USB.pm | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/PVE/QemuServer/USB.pm b/PVE/QemuServer/USB.pm
index 017ef9c0..be2bef29 100644
--- a/PVE/QemuServer/USB.pm
+++ b/PVE/QemuServer/USB.pm
@@ -62,6 +62,12 @@ EODESCR
." is irrelevant (all devices are plugged into a xhci controller).",
default => 0,
},
+ bootwhenmissing => {
+ optional => 1,
+ type => 'boolean',
+ description => "Specifies whether given mapped usb device is optional at vm boot.",
+ default => 0,
+ },
};
PVE::JSONSchema::register_format('pve-qm-usb', $usb_fmt);
@@ -75,7 +81,7 @@ our $usbdesc = {
PVE::JSONSchema::register_standard_option("pve-qm-usb", $usbdesc);
sub parse_usb_device {
- my ($value, $mapping) = @_;
+ my ($value, $mapping, $bootwhenmissing) = @_;
return if $value && $mapping; # not a valid configuration
@@ -98,7 +104,11 @@ sub parse_usb_device {
PVE::Mapping::USB::assert_valid($mapping, $devices->[0]);
};
if (my $err = $@) {
- die "USB Mapping invalid (hardware probably changed): $err\n";
+ if (defined($bootwhenmissing) && $bootwhenmissing == 1) {
+ print "USB Mapping invalid (hardware probably changed): $err\n";
+ } else {
+ die "USB Mapping invalid (hardware probably changed): $err\n";
+ }
}
my $device = $devices->[0];
@@ -228,7 +238,7 @@ sub print_usbdevice_full {
$usbdevice .= ",port=$port" if defined($port);
}
- my $parsed = parse_usb_device($device->{host}, $device->{mapping});
+ my $parsed = parse_usb_device($device->{host}, $device->{mapping}, $device->{bootwhenmissing});
if (defined($parsed->{vendorid}) && defined($parsed->{productid})) {
$usbdevice .= ",vendorid=0x$parsed->{vendorid},productid=0x$parsed->{productid}";
--
2.39.5
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
parent reply other threads:[~2024-11-26 10:37 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20241126015157.1107116-1-moddingfox@foxtek.us>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mailman.693.1732617417.391.pve-devel@lists.proxmox.com \
--to=pve-devel@lists.proxmox.com \
--cc=moddingfox@foxtek.us \
--cc=moddingfox@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox