mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
virUSBDeviceNew: Construct vroot path properly
When starting an LXC container, the /dev entries are created under temp root (/var/run/libvirt/lxc/$name.dev), relabelled and then the root is pivoted. However, when it comes to USB devices which keep path to the device in the structure we need a way to override the default /dev/usb/... path because we want to work with the one under temp root. That's what @vroot argument is for in virUSBDeviceNew. However, what is being passed there is: vroot = /var/run/libvirt/lxc/lxc_0.dev/bus/usb Therefore, constructed path is wrong: dev->path = //var/run/libvirt/lxc/lxc_0.dev/bus/usb//dev/bus/usb/002/002 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
12ba706d6d
commit
7b0ea999fc
@ -328,6 +328,7 @@ virUSBDeviceNew(unsigned int bus,
|
||||
const char *vroot)
|
||||
{
|
||||
virUSBDevicePtr dev;
|
||||
int rc;
|
||||
|
||||
if (VIR_ALLOC(dev) < 0)
|
||||
return NULL;
|
||||
@ -343,9 +344,16 @@ virUSBDeviceNew(unsigned int bus,
|
||||
virUSBDeviceFree(dev);
|
||||
return NULL;
|
||||
}
|
||||
if (virAsprintf(&dev->path, "%s" USB_DEVFS "%03d/%03d",
|
||||
vroot ? vroot : "",
|
||||
dev->bus, dev->dev) < 0) {
|
||||
|
||||
if (vroot) {
|
||||
rc = virAsprintf(&dev->path, "%s/%03d/%03d",
|
||||
vroot, dev->bus, dev->dev);
|
||||
} else {
|
||||
rc = virAsprintf(&dev->path, USB_DEVFS "%03d/%03d",
|
||||
dev->bus, dev->dev);
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
virUSBDeviceFree(dev);
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user