[pve-devel] [PATCH] add bridge hotplug
Alexandre DERUMIER
aderumier at odiso.com
Mon Aug 20 13:36:01 CEST 2012
>>You still call print_drivedevice_full() without bridges parameter. I guess that will cause problems?
No, no problem, I pass the $bridges hashref to build command line when vm start (to keep a list of bridges used).
But with hotplug, I hotplug the bridge before hotplug the device.
>> Note: print_pci_addr() does not check for uninitialized $bridges parameter! You should check that.
I'll do a patch.
----- Mail original -----
De: "Dietmar Maurer" <dietmar at proxmox.com>
À: "Alexandre Derumier" <aderumier at odiso.com>, pve-devel at pve.proxmox.com
Envoyé: Lundi 20 Août 2012 13:27:32
Objet: RE: [pve-devel] [PATCH] add bridge hotplug
You still call print_drivedevice_full() without bridges parameter. I guess that will cause problems?
Note: print_pci_addr() does not check for uninitialized $bridges parameter! You should check that.
> -----Original Message-----
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> bounces at pve.proxmox.com] On Behalf Of Alexandre Derumier
> Sent: Montag, 20. August 2012 13:07
> To: pve-devel at pve.proxmox.com
> Subject: [pve-devel] [PATCH] add bridge hotplug
>
>
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
> PVE/QemuServer.pm | 30 ++++++++++++++++++++++++++++++
> 1 files changed, 30 insertions(+), 0 deletions(-)
>
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index
> 8526e26..cc863d5 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -2350,6 +2350,8 @@ sub vm_deviceplug {
> my $devices_list = vm_devices_list($vmid);
> return 1 if defined($devices_list->{$deviceid});
>
> + qemu_bridgeadd($storecfg, $conf, $vmid, $deviceid); #add bridge if
> + we need it for the device
> +
> if ($deviceid =~ m/^(virtio)(\d+)$/) {
> return undef if !qemu_driveadd($storecfg, $vmid, $device);
> my $devicefull = print_drivedevice_full($storecfg, $conf, $vmid,
> $device); @@ -2389,6 +2391,14 @@ sub vm_deviceplug {
> }
> }
>
> + if ($deviceid =~ m/^(pci\.)(\d+)$/) {
> + my $bridgeid = $2;
> + my $pciaddr = print_pci_addr($deviceid);
> + my $devicefull = "pci-
> bridge,id=pci.$bridgeid,chassis_nr=$bridgeid$pciaddr";
> + qemu_deviceadd($vmid, $devicefull);
> + return undef if !qemu_deviceaddverify($vmid, $deviceid);
> + }
> +
> return 1;
> }
>
> @@ -2516,6 +2526,26 @@ sub qemu_findorcreatescsihw {
> return 1;
> }
>
> +sub qemu_bridgeadd {
> + my ($storecfg, $conf, $vmid, $device) = @_;
> +
> + my $bridges = {};
> + my $bridgeid = undef;
> + print_pci_addr($device, $bridges);
> +
> + while (my ($k, $v) = each %$bridges) {
> + $bridgeid = $k;
> + }
> + return if $bridgeid < 1;
> + my $bridge = "pci.$bridgeid";
> + my $devices_list = vm_devices_list($vmid);
> +
> + if(!defined($devices_list->{$bridge})) {
> + return undef if !vm_deviceplug($storecfg, $conf, $vmid, $bridge);
> + }
> + return 1;
> +}
> +
> sub qemu_netdevadd {
> my ($vmid, $conf, $device, $deviceid) = @_;
>
> --
> 1.7.2.5
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
--
--
Alexandre D e rumier
Ingénieur Systèmes et Réseaux
Fixe : 03 20 68 88 85
Fax : 03 20 68 90 88
45 Bvd du Général Leclerc 59100 Roubaix
12 rue Marivaux 75002 Paris
More information about the pve-devel
mailing list