• L
    qemu: fix handling of default/implicit devices for q35 · c27b0bb1
    Laine Stump 提交于
    This patch adds in special handling for a few devices that need to be
    treated differently for q35 domains:
    
    usb - there is no implicit/default usb controller for the q35
    machinetype. This is done because normally the default usb controller
    is added to a domain by just adding "-usb" to the qemu commandline,
    and it's assumed that this will add a single piix3 usb1 controller at
    slot 1 function 2. That's not what happens when the machinetype is
    q35, though. Instead, adding -usb to the commandline adds 3 usb
    (version 2) controllers to the domain at slot 0x1D.{1,2,7}. Rather
    than having
    
      <controller type='usb' index='0'/>
    
    translate into 3 separate devices on the PCI bus, it's cleaner to not
    automatically add a default usb device; one can always be added
    explicitly if desired. Or we may decide that on q35 machines, 3 usb
    controllers will be automatically added when none is given. But for
    this initial commit, at least we aren't locking ourselves into
    something we later won't want.
    
    video - qemu always initializes the primary video device immediately
    after any integrated devices for the machinetype. Unless instructed
    otherwise (by using "-device vga..." instead of "-vga" which libvirt
    uses in many cases to work around deficiencies and bugs in various
    qemu versions) qemu will always pick the first unused slot. In the
    case of the "pc" machinetype and its derivatives, this is always slot
    2, but on q35 machinetypes, the first free slot is slot 1 (since the
    q35's integrated peripheral devices are placed in other slots,
    e.g. slot 0x1f). In order to make the PCI address of the video device
    predictable, that slot (1 or 2, depending on machinetype) is reserved
    even when no video device has been specified.
    
    sata - a q35 machine always has a sata controller implicitly added at
    slot 0x1F, function 2. There is no way to avoid this controller, so we
    always add it. Note that the xml2xml tests for the pcie-root and q35
    cases were changed to use DO_TEST_DIFFERENT() so that we can check for
    the sata controller being automatically added. This is especially
    important because we can't check for it in the xml2argv output (it has
    no effect on that output since it's an implicit device).
    
    ide - q35 has no ide controllers.
    
    isa and smbus controllers - these two are always present in a q35 (at
    slot 0x1F functions 0 and 3) but we have no way of modelling them in
    our config. We do need to reserve those functions so that the user
    doesn't attempt to put anything else there though. (note that the "pc"
    machine type also has an ISA controller, which we also ignore).
    c27b0bb1
qemuxml2argvtest.c 43.0 KB