1. 08 3月, 2019 2 次提交
    • E
      snapshot: Give virDomainSnapshotDefFormat its own flags · c5029559
      Eric Blake 提交于
      virDomainSnapshotDefFormat currently takes two sets of knobs:
      an 'unsigned int flags' argument that can currently just be
      VIR_DOMAIN_DEF_FORMAT_SECURE, and an 'int internal' argument used as
      a bool to determine whether to output an additional element.  It
      then reuses the 'flags' knob to call into virDomainDefFormatInternal(),
      which takes a different set of flags. In fact, prior to commit 0ecd6851
      (1.2.12), the 'flags' argument actually took the public
      VIR_DOMAIN_XML_SECURE, which was even more confusing.  Let's borrow
      from the style of that earlier commit, by introducing a function
      for translating from the public flags (VIR_DOMAIN_SNAPSHOT_XML_SECURE
      was just recently introduced) into a new enum specific to snapshot
      formatting, and adjust all callers to use snapshot-specific enum
      values when formatting, and where the formatter now uses a new
      variable 'domainflags' to make it obvious when we are translating
      from snapshot flags back to domain flags.  We don't even have to
      use the conversion function for drivers that don't accept the
      public VIR_DOMAIN_SNAPSHOT_XML_SECURE flag.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      c5029559
    • E
      snapshot: Rework virDomainSnapshotState enum · f43eb680
      Eric Blake 提交于
      The existing virDomainSnapshotState is a superset of virDomainState,
      adding one more state (disk-snapshot) on top of valid domain states.
      But as written, the enum cannot be used for gcc validation that all
      enum values are covered in a strongly-typed switch condition, because
      the enum does not explicitly include the values it is adding to.
      
      Copy the style used in qemu_blockjob.h of creating new enum names
      for every inherited value, and update most clients to use the new
      enum names anywhere snapshot state is referenced. The exception is
      two switch statements in qemu code, which instead gain a fixme
      comment about odd type usage (which will be cleaned up in the next
      patch). The rest of the patch is fairly mechanical (I actually did
      it by temporarily s/state/xstate/ in snapshot_conf.h to let the
      compiler find which spots in the code used the field, did the
      obvious search and replace in those functions, then undid the rename).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      f43eb680
  2. 05 3月, 2019 1 次提交
    • C
      qemu: Support scsi controller model=virtio-{non-}transitional · 448a0947
      Cole Robinson 提交于
      Add <controller type='scsi' model handling for virtio transitional
      devices. Ex:
      
        <controller type='scsi' model='virtio-transitional'/>
      
      * "virtio-transitional" maps to qemu "virtio-scsi-pci-transitional"
      * "virtio-non-transitional" maps to qemu "virtio-scsi-non-transitional"
      
      The naming here doesn't match the pre-existing model=virtio-scsi.
      The prescence of '-scsi' there seems kind of redundant as we have
      type='scsi' already, so I decided to follow the pattern of other
      patches and use virtio-transitional etc.
      Reviewed-by: NAndrea Bolognani <abologna@redhat.com>
      Signed-off-by: NCole Robinson <crobinso@redhat.com>
      448a0947
  3. 20 2月, 2019 1 次提交
    • E
      domain: Fix unknown flags diagnosis in virDomainGetXMLDesc · 27c8fd74
      Eric Blake 提交于
      Many drivers had a comment that they did not validate the incoming
      'flags' to virDomainGetXMLDesc() because they were relying on
      virDomainDefFormat() to do it instead. This used to be the case
      (at least since 461e0f1a and friends in 0.9.4 added unknown flag
      checking in general), but regressed in commit 0ecd6851 (1.2.12),
      when all of the drivers were changed to pass 'flags' through the
      new helper virDomainDefFormatConvertXMLFlags(). Since this helper
      silently ignores unknown flags, we need to implement flag checking
      in each driver instead.
      
      Annoyingly, this means that any new flag values added will silently
      be ignored when targeting an older libvirt, rather than our usual
      practice of loudly diagnosing an unsupported flag.  Add comments
      in domain_conf.[ch] to remind us to be extra vigilant about the
      impact when adding flags (a new flag to add data is safe if the
      older server omitting the requested data doesn't break things in
      the newer client; a new flag to suppress data rather than enhancing
      the existing VIR_DOMAIN_XML_SECURE may form a data leak or even a
      security hole).
      
      In the qemu driver, there are multiple callers all funnelling to
      qemuDomainDefFormatBufInternal(); many of them already validated
      flags (and often only a subset of the full set of possible flags),
      but for ease of maintenance, we can also check flags at the common
      helper function.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      27c8fd74
  4. 12 6月, 2018 2 次提交
  5. 18 4月, 2018 1 次提交
    • M
      virobject: Introduce VIR_CLASS_NEW() macro · 10f94828
      Michal Privoznik 提交于
      So far we are repeating the following lines over and over:
      
        if (!(virSomeObjectClass = virClassNew(virClassForObject(),
                                   "virSomeObject",
                                   sizeof(virSomeObject),
                                   virSomeObjectDispose)))
            return -1;
      
      While this works, it is impossible to do some checking. Firstly,
      the class name (the 2nd argument) doesn't match the name in the
      code in all cases (the 3rd argument). Secondly, the current style
      is needlessly verbose. This commit turns example into following:
      
        if (!(VIR_CLASS_NEW(virSomeObject,
                            virClassForObject)))
            return -1;
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      10f94828
  6. 12 4月, 2018 6 次提交
  7. 05 3月, 2018 16 次提交
  8. 20 2月, 2018 1 次提交
    • D
      conf: add enum constants for default controller models · a302480d
      Daniel P. Berrangé 提交于
      The controller model is slightly unusual in that the default value is
      -1, not 0. As a result the default value is not covered by any of the
      existing enum cases. This in turn means that any switch() statements
      that think they have covered all cases, will in fact not match the
      default value at all. In the qemuDomainDeviceCalculatePCIConnectFlags()
      method this has caused a serious mistake where we fallthrough from the
      SCSI controller case, to the VirtioSerial controller case, and from
      the USB controller case to the IDE controller case.
      
      By adding explicit enum constant starting at -1, we can ensure switches
      remember to handle the default case.
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      a302480d
  9. 03 2月, 2018 1 次提交
    • L
      vbox: fix SEGV during dumpxml of a serial port · 9c27e464
      Laine Stump 提交于
      commit 77a12987 changed the "virDomainChrSourceDef source" inside
      virDomainChrDef to "virDomainChrSourceDefPtr source", and started
      allocating source inside virDomainChrDefNew(), but vboxDumpSerial()
      was allocating a virDomainChrDef with a simple VIR_ALLOC() (i.e. never
      calling virDomainChrDefNew()), so source was never initialized,
      leading to a SEGV any time a serial port was present. The same problem
      was created in vboxDumpParallel().
      
      This patch changes vboxDumpSerial() and vboxDumpParallel() to use
      virDomainChrDefNew() instead of VIR_ALLOC(), and changes both of those
      functions to return an error if virDomainChrDef() (or any other
      allocation) fails.
      
      This resolves: https://bugzilla.redhat.com/1536649
      9c27e464
  10. 01 2月, 2018 1 次提交
    • J
      conf: Rework and rename virDomainDeviceFindControllerModel · 932862b8
      John Ferlan 提交于
      As it turns out virDomainDeviceFindControllerModel was only ever
      called for SCSI controllers using VIR_DOMAIN_CONTROLLER_TYPE_SCSI
      as a parameter.
      
      So rename to virDomainDeviceFindSCSIController and rather than
      return a model, let's return a virDomainControllerDefPtr to let
      the caller reference whatever it wants.
      932862b8
  11. 25 11月, 2017 1 次提交
  12. 08 11月, 2017 7 次提交
    • D
      vbox: Add SAS controller support · 8b5eefb6
      Dawid Zamirski 提交于
      In VirtualBox SAS and SCSI are separate controller types whereas libvirt
      does not make such distinction. This patch adds support for attaching
      the VBOX SAS controllers by mapping the 'lsisas1068' controller model in
      libvirt XML to VBOX SAS controller type. If VBOX VM has disks attached
      to both SCSI and SAS controller libvirt domain XML will have two
      <controller type='scsci'> elements with index and model attributes set
      accordingly. In this case, each respective <disk> element must have
      <address> element specified to assign it to respective SCSI controller.
      8b5eefb6
    • D
      vbox: Generate disk address element in dumpxml · e0054c0e
      Dawid Zamirski 提交于
      This patch adds <address> element to each <disk> device since device
      names alone won't adequately reflect the storage device layout in the
      VM. With this patch, the ouput produced by dumpxml will faithfully
      reproduce the storage layout of the VM if used with define.
      e0054c0e
    • D
      vbox: Process empty removable disks in dumpxml · 7c0a85e5
      Dawid Zamirski 提交于
      Previously any removable storage device without media attached was
      omitted from domain XML dump. They're still (rightfully) omitted in
      snapshot XML dump but need to be accounted properly to for the device
      names to stay in 'sync' between domain and snapshot XML dumps.
      7c0a85e5
    • D
      vbox: Cleanup vboxDumpDisks implementation · 08b995c8
      Dawid Zamirski 提交于
      Primer the code for further changes:
      
      * move variable declarations to the top of the function
      * group together free/release statements
      * error check and report VBOX API calls used
      08b995c8
    • D
      vbox: Correctly generate drive name in dumpxml · a4919338
      Dawid Zamirski 提交于
      If a VBOX VM has e.g. a SATA and SCSI disk attached, the XML generated
      by dumpxml used to produce "sda" for both of those disks. This is an
      invalid domain XML as libvirt does not allow duplicate device names. To
      address this, keep the running total of disks that will use "sd" prefix
      for device name and pass it to the vboxGenerateMediumName which no
      longer tries to "compute" the value based only on current and max
      port and slot values. After this the vboxGetMaxPortSlotValues is not
      needed and was deleted.
      a4919338
    • D
      vbox: Swap vboxSnapshotGetReadOnlyDisks arguments · 32a94411
      Dawid Zamirski 提交于
      So that the function signature matches vboxSnapshotGetReadWriteDisks
      32a94411
    • D
      vbox: Do not free disk definitions on cleanup · 03a24da4
      Dawid Zamirski 提交于
      Both vboxSnapshotGetReadWriteDisks and vboxSnapshotGetReadWriteDisks do
      not need to free the def->disks on cleanup because it's being done by
      the caller via virDomainSnaphotDefFree
      03a24da4