Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

14.2. Attaching and Updating a Device with virsh


For information on attaching storage devices refer to Section 13.3.1, “Adding File-based Storage to a Guest”

Procedure 14.1. Hot plugging USB devices for use by the guest virtual machine

The following procedure demonstrates how to attach USB devices to the guest virtual machine. This can be done while the guest virtual machine is running as a hotplug procedure or it can be done while the guest is shutoff. The device you want to emulate needs to be attached to the host physical machine.
  1. Locate the USB device you want to attach with the following command:
    # lsusb -v
    
    idVendor           0x17ef Lenovo
    idProduct          0x480f Integrated Webcam [R5U877]
    
    
    Copy to Clipboard Toggle word wrap
  2. Create an XML file and give it a logical name (usb_device.xml, for example). Make sure you copy the vendor and product IDs exactly as was displayed in your search.
       <hostdev mode='subsystem' type='usb' managed='yes'>
          <source>
            <vendor id='0x17ef'/>
            <product id='0x480f'/>
          </source>
        </hostdev>
      ...
    
    
    Copy to Clipboard Toggle word wrap

    Figure 14.1. USB Devices XML Snippet

  3. Attach the device with the following command:
    # virsh attach-device rhel6 --file usb_device.xml --config
    Copy to Clipboard Toggle word wrap
    In this example [rhel6] is the name of your guest virtual machine and [usb_device.xml] is the file you created in the previous step. If you want to have the change take effect in the next reboot, use the --config option. If you want this change to be persistent, use the --persistent option. If you want the change to take effect on the current domain, use the --current option. See the Virsh man page for additional information.
  4. If you want to detach the device (hot unplug), perform the following command:
    # virsh detach-device rhel6 --file usb_device.xml
    Copy to Clipboard Toggle word wrap
    In this example [rhel6] is the name of your guest virtual machine and [usb_device.xml] is the file you attached in the previous step
Nach oben
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2025 Red Hat