1. 10 3月, 2011 5 次提交
    • E
      audit: also audit cgroup ACL permissions · 340ab27d
      Eric Blake 提交于
      * src/qemu/qemu_audit.h (qemuAuditCgroupMajor)
      (qemuAuditCgroupPath): Add parameter.
      * src/qemu/qemu_audit.c (qemuAuditCgroupMajor)
      (qemuAuditCgroupPath): Add 'acl=rwm' to cgroup audit entries.
      * src/qemu/qemu_cgroup.c: Update clients.
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Likewise.
      340ab27d
    • E
      cgroup: allow fine-tuning of device ACL permissions · 5564c575
      Eric Blake 提交于
      Adding audit points showed that we were granting too much privilege
      to qemu; it should not need any mknod rights to recreate any
      devices.  On the other hand, lxc should have all device privileges.
      The solution is adding a flag parameter.
      
      This also lets us restrict write access to read-only disks.
      
      * src/util/cgroup.h (virCgroup*Device*): Adjust prototypes.
      * src/util/cgroup.c (virCgroupAllowDevice)
      (virCgroupAllowDeviceMajor, virCgroupAllowDevicePath)
      (virCgroupDenyDevice, virCgroupDenyDeviceMajor)
      (virCgroupDenyDevicePath): Add parameter.
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Update clients.
      * src/lxc/lxc_controller.c (lxcSetContainerResources): Likewise.
      * src/qemu/qemu_cgroup.c: Likewise.
      (qemuSetupDiskPathAllow): Also, honor read-only disks.
      5564c575
    • E
      audit: rename remaining qemu audit functions · 48096a00
      Eric Blake 提交于
      Also add ATTRIBUTE_NONNULL markers.
      
      * src/qemu/qemu_audit.h: The pattern qemuDomainXXXAudit is
      inconsistent; prefer qemuAuditXXX instead.
      * src/qemu/qemu_audit.c: Reflect the renames.
      * src/qemu/qemu_driver.c: Likewise.
      * src/qemu/qemu_hotplug.c: Likewise.
      * src/qemu/qemu_migration.c: Likewise.
      * src/qemu/qemu_process.c: Likewise.
      48096a00
    • E
      audit: also audit cgroup controller path · f2512684
      Eric Blake 提交于
      Although the cgroup device ACL controller path can be worked out
      by researching the code, it is more efficient to include that
      information directly in the audit message.
      
      * src/util/cgroup.h (virCgroupPathOfController): New prototype.
      * src/util/cgroup.c (virCgroupPathOfController): Export.
      * src/libvirt_private.syms: Likewise.
      * src/qemu/qemu_audit.c (qemuAuditCgroup): Use it.
      f2512684
    • E
      audit: split cgroup audit types to allow more information · d04916fa
      Eric Blake 提交于
      Device names can be manipulated, so it is better to also log
      the major/minor device number corresponding to the cgroup ACL
      changes that libvirt made.  This required some refactoring
      of the relatively new qemu cgroup audit code.
      
      Also, qemuSetupChardevCgroup was only auditing on failure, not success.
      
      * src/qemu/qemu_audit.h (qemuDomainCgroupAudit): Delete.
      (qemuAuditCgroup, qemuAuditCgroupMajor, qemuAuditCgroupPath): New
      prototypes.
      * src/qemu/qemu_audit.c (qemuDomainCgroupAudit): Rename...
      (qemuAuditCgroup): ...and drop a parameter.
      (qemuAuditCgroupMajor, qemuAuditCgroupPath): New functions, to
      allow listing device major/minor in audit.
      (qemuAuditGetRdev): New helper function.
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Adjust callers.
      * src/qemu/qemu_cgroup.c (qemuSetupDiskPathAllow)
      (qemuSetupHostUsbDeviceCgroup, qemuSetupCgroup)
      (qemuTeardownDiskPathDeny): Likewise.
      (qemuSetupChardevCgroup): Likewise, fixing missing audit.
      d04916fa
  2. 09 3月, 2011 3 次提交
    • E
      audit: tweak audit messages to match conventions · 30ad4883
      Eric Blake 提交于
      * src/qemu/qemu_audit.c (qemuDomainHostdevAudit): Avoid use of
      "type", which has a pre-defined meaning.
      (qemuDomainCgroupAudit): Likewise, as well as "item".
      30ad4883
    • C
      Don't overwrite virRun error messages · 91893014
      Cole Robinson 提交于
      virRun gives pretty useful error output, let's not overwrite it unless there
      is a good reason. Some places were providing more information about what
      the commands were _attempting_ to do, however that's usually less useful from
      a debugging POV than what actually happened.
      91893014
    • H
      Fix a wrong error message thrown to user · 83d35233
      Hu Tao 提交于
      * src/qemu/qemu_driver.c: qemuDomainUpdateDeviceFlags() is not disk
        specific as the message suggests
      83d35233
  3. 08 3月, 2011 3 次提交
  4. 06 3月, 2011 1 次提交
    • O
      qemu: Support vram for video of qxl type · 82dfc6f3
      Osier Yang 提交于
      For qemu names the primary vga as "qxl-vga":
      
        1) if vram is specified for 2nd qxl device:
      
          -vga qxl -global qxl-vga.vram_size=$SIZE \
          -device qxl,id=video1,vram_size=$SIZE,...
      
        2) if vram is not specified for 2nd qxl device, (use the default
           set by global):
      
          -vga qxl -global qxl-vga.vram_size=$SIZE \
          -device qxl,id=video1,...
      
      For qemu names all qxl devices as "qxl":
      
        1) if vram is specified for 2nd qxl device:
      
          -vga qxl -global qxl.vram_size=$SIZE \
          -device qxl,id=video1,vram_size=$SIZE ...
      
        2) if vram is not specified for 2nd qxl device:
      
          -vga qxl -global qxl-vga.vram_size=$SIZE \
          -device qxl,id=video1,...
      
      "-global" is the only way to define vram_size for the primary qxl
      device, regardless of how qemu names it, (It's not good a good
      way, as original idea of "-global" is to set a global default for
      a driver property, but to specify vram for first qxl device, we
      have to use it).
      
      For other qxl devices, as they are represented by "-device", could
      specify it directly and seperately for each, and it overrides the
      default set by "-global" if specified.
      
      v1 - v2:
        * modify "virDomainVideoDefaultRAM" so that it returns 16M as the
          default vram_size for qxl device.
      
        * vram_size * 1024 (qemu accepts bytes for vram_size).
      
        * apply default vram_size for qxl device for which vram_size is
          not specified.
      
        * modify "graphics-spice" tests (more sensiable vram_size)
      
        * Add an argument of virDomainDefPtr type for qemuBuildVideoDevStr,
          to use virDomainVideoDefaultRAM in qemuBuildVideoDevStr).
      
      v2 - v3:
        * Modify default video memory size for qxl device from 16M to 24M
      
        * Update codes to be consistent with changes on qemu_capabilities.*
      82dfc6f3
  5. 04 3月, 2011 2 次提交
    • L
      qemu: avoid corruption of domain hashtable and misuse of freed domains · f8ac6790
      Laine Stump 提交于
      This was also found while investigating
      
         https://bugzilla.redhat.com/show_bug.cgi?id=670848
      
      An EOF on a domain's monitor socket results in an event being queued
      to handle the EOF. The handler calls qemuProcessHandleMonitorEOF. If
      it is a transient domain, this leads to a call to
      virDomainRemoveInactive, which removes the domain from the driver's
      hashtable and unref's it. Nowhere in this code is the qemu driver lock
      acquired.
      
      However, all modifications to the driver's domain hashtable *must* be
      done while holding the driver lock, otherwise the hashtable can become
      corrupt, and (even more likely) another thread could call a different
      hashtable function and acquire a pointer to the domain that is in the
      process of being destroyed.
      
      To prevent such a disaster, qemuProcessHandleMonitorEOF must get the
      qemu driver lock *before* it gets the DomainObj's lock, and hold it
      until it is finished with the DomainObj. This guarantees that nobody
      else modifies the hashtable at the same time, and that anyone who had
      already gotten the DomainObj from the hashtable prior to this call has
      finished with it before we remove/destroy it.
      f8ac6790
    • L
      qemu: Add missing lock of virDomainObj before calling virDomainUnref · e570ca12
      Laine Stump 提交于
      This was found while researching the root cause of:
      
      https://bugzilla.redhat.com/show_bug.cgi?id=670848
      
      virDomainUnref should only be called with the lock held for the
      virDomainObj in question. However, when a transient qemu domain gets
      EOF on its monitor socket, it queues an event which frees the monitor,
      which unref's the virDomainObj without first locking it. If another
      thread has already locked the virDomainObj, the modification of the
      refcount could potentially be corrupted. In an extreme case, it could
      also be potentially unlocked by virDomainObjFree, thus left open to
      modification by anyone else who would have otherwise waited for the
      lock (not to mention the fact that they would be accessing freed
      data!).
      
      The solution is to have qemuMonitorFree lock the domain object right
      before unrefing it. Since the caller to qemuMonitorFree doesn't expect
      this lock to be held, if the refcount doesn't go all the way to 0,
      qemuMonitorFree must unlock it after the unref.
      e570ca12
  6. 02 3月, 2011 1 次提交
    • E
      qemu: avoid double close on domain restore · 4f805dcd
      Eric Blake 提交于
      qemudDomainSaveImageStartVM was evil - it closed the incoming fd
      argument on some, but not all, code paths, without informing the
      caller about that action.  No wonder that this resulted in
      double-closes: https://bugzilla.redhat.com/show_bug.cgi?id=672725
      
      * src/qemu/qemu_driver.c (qemudDomainSaveImageStartVM): Alter
      signature, to avoid double-close.
      (qemudDomainRestore, qemudDomainObjRestore): Update callers.
      4f805dcd
  7. 01 3月, 2011 1 次提交
    • E
      qemu: only request sound cgroup ACL when required · 7c6b22c4
      Eric Blake 提交于
      When a SPICE or VNC graphics controller is present, and sound is
      piggybacked over a channel to the graphics device rather than
      directly accessing host hardware, then there is no need to grant
      host hardware access to that qemu process.
      
      * src/qemu/qemu_cgroup.c (qemuSetupCgroup): Prevent sound with
      spice, and with vnc when vnc_allow_host_audio is 0.
      Reported by Daniel Berrange.
      7c6b22c4
  8. 25 2月, 2011 7 次提交
    • D
      Allow hash tables to use generic pointers as keys · 16ba2aaf
      Daniel P. Berrange 提交于
      Relax the restriction that the hash table key must be a string
      by allowing an arbitrary hash code generator + comparison func
      to be provided
      
      * util/hash.c, util/hash.h: Allow any pointer as a key
      * internal.h: Include stdbool.h as standard.
      * conf/domain_conf.c, conf/domain_conf.c,
        conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
        nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
        qemu/qemu_command.c, qemu/qemu_driver.c,
        qemu/qemu_process.c, uml/uml_driver.c,
        xen/xm_internal.c: s/char */void */ in hash callbacks
      16ba2aaf
    • D
      Remove deallocator parameter from hash functions · 6952708c
      Daniel P. Berrange 提交于
      Since the deallocator is passed into the constructor of
      a hash table it is not desirable to pass it into each
      function again. Remove it from all functions, but provide
      a virHashSteal to allow a item to be removed from a hash
      table without deleteing it.
      
      * src/util/hash.c, src/util/hash.h: Remove deallocator
        param from all functions. Add virHashSteal
      * src/libvirt_private.syms: Add virHashSteal
      * src/conf/domain_conf.c, src/conf/nwfilter_params.c,
        src/nwfilter/nwfilter_learnipaddr.c,
        src/qemu/qemu_command.c, src/xen/xm_internal.c: Update
        for changed hash API
      6952708c
    • E
      audit: audit qemu pci and usb device passthrough · 1aaef5ad
      Eric Blake 提交于
      * src/qemu/qemu_audit.h (qemuDomainHostdevAudit): New prototype.
      * src/qemu/qemu_audit.c (qemuDomainHostdevAudit): New function.
      (qemuDomainStartAudit): Call as appropriate.
      * src/qemu/qemu_hotplug.c (qemuDomainAttachHostPciDevice)
      (qemuDomainAttachHostUsbDevice, qemuDomainDetachHostPciDevice)
      (qemuDomainDetachHostUsbDevice): Likewise.
      1aaef5ad
    • E
      audit: audit qemu memory and vcpu adjusments · e25f2c74
      Eric Blake 提交于
      * src/qemu/qemu_audit.h (qemuDomainMemoryAudit)
      (qemuDomainVcpuAudit): New prototypes.
      * src/qemu/qemu_audit.c (qemuDomainResourceAudit)
      (qemuDomainMemoryAudit, qemuDomainVcpuAudit): New functions.
      (qemuDomainStartAudit): Call as appropriate.
      * src/qemu/qemu_driver.c (qemudDomainSetMemory)
      (qemudDomainHotplugVcpus): Likewise.
      e25f2c74
    • E
      audit: add qemu hooks for auditing cgroup events · 6bb98d41
      Eric Blake 提交于
      * src/qemu/qemu_audit.h (qemuDomainCgroupAudit): New prototype.
      * src/qemu/qemu_audit.c (qemuDomainCgroupAudit): Implement it.
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Add audit.
      * src/qemu/qemu_cgroup.c (qemuSetupDiskPathAllow)
      (qemuSetupChardevCgroup, qemuSetupHostUsbDeviceCgroup)
      (qemuSetupCgroup, qemuTeardownDiskPathDeny): Likewise.
      6bb98d41
    • E
      audit: prepare qemu for listing vm in cgroup audits · b4d3434f
      Eric Blake 提交于
      * src/qemu/qemu_cgroup.h (struct qemuCgroupData): New helper type.
      (qemuSetupDiskPathAllow, qemuSetupChardevCgroup)
      (qemuTeardownDiskPathDeny): Drop unneeded prototypes.
      (qemuSetupDiskCgroup, qemuTeardownDiskCgroup): Adjust prototype.
      * src/qemu/qemu_cgroup.c
      (qemuSetupDiskPathAllow, qemuSetupChardevCgroup)
      (qemuTeardownDiskPathDeny): Mark static and use new type.
      (qemuSetupHostUsbDeviceCgroup): Use new type.
      (qemuSetupDiskCgroup): Alter signature.
      (qemuSetupCgroup): Adjust caller.
      * src/qemu/qemu_hotplug.c (qemuDomainAttachHostUsbDevice)
      (qemuDomainDetachPciDiskDevice, qemuDomainDetachSCSIDiskDevice):
      Likewise.
      * src/qemu/qemu_driver.c (qemudDomainAttachDevice)
      (qemuDomainUpdateDeviceFlags): Likewise.
      b4d3434f
    • E
      cgroup: determine when skipping non-devices · 06173876
      Eric Blake 提交于
      * src/util/cgroup.c (virCgroupAllowDevicePath)
      (virCgroupDenyDevicePath): Don't fail with EINVAL for
      non-devices.
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Update caller.
      * src/qemu/qemu_cgroup.c (qemuSetupDiskPathAllow)
      (qemuSetupChardevCgroup, qemuSetupHostUsbDeviceCgroup)
      (qemuSetupCgroup, qemuTeardownDiskPathDeny): Likewise.
      06173876
  9. 24 2月, 2011 5 次提交
  10. 23 2月, 2011 1 次提交
    • E
      security: avoid memory leak · 009fce98
      Eric Blake 提交于
      Leak introduced in commit d6623003.
      
      * src/qemu/qemu_driver.c (qemuSecurityInit): Avoid leak on failure.
      * src/security/security_stack.c (virSecurityStackClose): Avoid
      leaking component drivers.
      009fce98
  11. 22 2月, 2011 1 次提交
    • W
      protect the scsi controller to be deleted when it is in use · cf61114c
      Wen Congyang 提交于
      Steps to reproduce this bug:
      1. virsh attach-disk domain --source imagefile --target sdb --sourcetype file --driver qemu --subdriver raw
      2. virsh detach-device controller.xml # remove scsi controller 0
      3. virsh detach-disk domain sdb
         error: Failed to detach disk
         error: operation failed: detaching scsi0-0-1 device failed: Device 'scsi0-0-1' not found
      
      I think we should not detach a controller when it is used by some other device.
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      cf61114c
  12. 21 2月, 2011 2 次提交
    • E
      maint: kill all remaining uses of old DEBUG macro · 994e7567
      Eric Blake 提交于
      Done mechanically with:
      $ git grep -l '\bDEBUG0\? *(' | xargs -L1 sed -i 's/\bDEBUG0\? *(/VIR_&/'
      
      followed by manual deletion of qemudDebug in daemon/libvirtd.c, along
      with a single 'make syntax-check' fallout in the same file, and the
      actual deletion in src/util/logging.h.
      
      * src/util/logging.h (DEBUG, DEBUG0): Delete.
      * daemon/libvirtd.h (qemudDebug): Likewise.
      * global: Change remaining clients over to VIR_DEBUG counterpart.
      994e7567
    • E
      hash: make virHashFree more free-like · 03ba07cb
      Eric Blake 提交于
      Two-argument free functions are uncommon; match the style elsewhere
      by caching the callback at creation.
      
      * src/util/hash.h (virHashCreate, virHashFree): Move deallocator
      argument to creation.
      * cfg.mk (useless_free_options): Add virHashFree.
      * src/util/hash.c (_virHashTable): Track deallocator.
      (virHashCreate, virHashFree): Update to new signature.
      * src/conf/domain_conf.c (virDomainObjListDeinit)
      (virDomainObjListInit, virDomainDiskDefForeachPath)
      (virDomainSnapshotObjListDeinit, virDomainSnapshotObjListInit):
      Update callers.
      * src/conf/nwfilter_params.c (virNWFilterHashTableFree)
      (virNWFilterHashTableCreate): Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterTriggerVMFilterRebuild):
      Likewise.
      * src/cpu/cpu_generic.c (genericHashFeatures, genericBaseline):
      Likewise.
      * src/xen/xm_internal.c (xenXMOpen, xenXMClose): Likewise.
      * src/nwfilter/nwfilter_learnipaddr.c (virNWFilterLearnInit)
      (virNWFilterLearnShutdown): Likewise.
      * src/qemu/qemu_command.c (qemuDomainPCIAddressSetCreate)
      (qemuDomainPCIAddressSetFree): Likewise.
      * src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
      03ba07cb
  13. 18 2月, 2011 8 次提交
    • J
      Do not add drive 'boot=on' param when a kernel is specified · efc2594b
      Jim Fehlig 提交于
      libvirt-tck was failing several domain tests [1] with qemu 0.14, which
      is now less tolerable of specifying 2 bootroms with the same boot index [2].
      
      Drop the 'boot=on' param if kernel has been specfied.
      
      [1] https://www.redhat.com/archives/libvir-list/2011-February/msg00559.html
      [2] http://lists.nongnu.org/archive/html/qemu-devel/2011-02/msg01892.html
      efc2594b
    • C
      remove duplicated call to reportOOMError · 50daaa0a
      Christophe Fergeau 提交于
      50daaa0a
    • C
      don't check for NULL before calling virHashFree · 7b9a5099
      Christophe Fergeau 提交于
      virHashFree follows the convention described in HACKING that
      XXXFree() functions can be called with a NULL argument.
      7b9a5099
    • C
      remove no longer needed calls to virReportOOMError · 9905c69e
      Christophe Fergeau 提交于
      Now that the virHash handling functions call virReportOOMError by
      themselves when needed, users of the virHash API no longer need to
      do it by themselves. Since users of the virHash API were not
      consistently calling virReportOOMError after memory failures from
      the virHash code, this has the added benefit of making OOM
      reporting from this code more consistent and reliable.
      9905c69e
    • W
      check more error info about whether drive_add failed · 34c13d0d
      Wen Congyang 提交于
      When we attach a disk, but we specify a wrong format of disk image,
      qemu monitor command drive_add will fail, but libvirt does not detect
      this error.
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      34c13d0d
    • L
      Allow brAddTap to create a tap device that is down · 13ae7a02
      Laine Stump 提交于
      An upcoming patch has a use for a tap device to be created that
      doesn't need to be actually put into the "up" state, and keeping it
      "down" keeps the output of ifconfig from being unnecessarily cluttered
      (ifconfig won't show down interfaces unless you add "-a").
      
      bridge.[ch]: add "up" as an arg to brAddTap()
      uml_conf.c, qemu_command.c: add "up" (set to "true") to brAddTap() call.
      13ae7a02
    • L
      Add txmode attribute to interface XML for virtio backend · e9bd5c0e
      Laine Stump 提交于
      This is in response to:
      
         https://bugzilla.redhat.com/show_bug.cgi?id=629662
      
      Explanation
      
      qemu's virtio-net-pci driver allows setting the algorithm used for tx
      packets to either "bh" or "timer". This is done by adding ",tx=bh" or
      ",tx=timer" to the "-device virtio-net-pci" commandline option.
      
      'bh' stands for 'bottom half'; when this is set, packet tx is all done
      in an iothread in the bottom half of the driver. (In libvirt, this
      option is called the more descriptive "iothread".)
      
      'timer' means that tx work is done in qemu, and if there is more tx
      data than can be sent at the present time, a timer is set before qemu
      moves on to do other things; when the timer fires, another attempt is
      made to send more data. (libvirt retains the name "timer" for this
      option.)
      
      The resulting difference, according to the qemu developer who added
      the option is:
      
          bh makes tx more asynchronous and reduces latency, but potentially
          causes more processor bandwidth contention since the cpu doing the
          tx isn't necessarily the cpu where the guest generated the
          packets.
      
      Solution
      
      This patch provides a libvirt domain xml knob to change the option on
      the qemu commandline, by adding a new attribute "txmode" to the
      <driver> element that can be placed inside any <interface> element in
      a domain definition. It's use would be something like this:
      
          <interface ...>
            ...
            <model type='virtio'/>
            <driver txmode='iothread'/>
            ...
          </interface>
      
      I chose to put this setting as an attribute to <driver> rather than as
      a sub-element to <tune> because it is specific to the virtio-net
      driver, not something that is generally usable by all network drivers.
      (note that this is the same placement as the "driver name=..."
      attribute used to choose kernel vs. userland backend for the
      virtio-net driver.)
      
      Actually adding the tx=xxx option to the qemu commandline is only done
      if the version of qemu being used advertises it in the output of
      
          qemu -device virtio-net-pci,?
      
      If a particular txmode is requested in the XML, and the option isn't
      listed in that help output, an UNSUPPORTED_CONFIG error is logged, and
      the domain fails to start.
      e9bd5c0e
    • L
      Restructure domain struct interface "driver" data for easier expansion · b670a412
      Laine Stump 提交于
      When the <driver> element (and its "name" attribute) was added to the
      domain XML's interface element, a "backend" enum was simply added to
      the toplevel of the virDomainNetDef struct.
      
      Ignoring the naming inconsistency ("name" vs. "backend"), this is fine
      when there's only a single item contained in the driver element of the
      XML, but doesn't scale well as we add more attributes that apply to
      the backend of the virtio-net driver, or add attributes applicable to
      other drivers.
      
      This patch changes virDomainNetDef in two ways:
      
      1) Rename the item in the struct from "backend" to "name", so that
         it's the same in the XML and in the struct, hopefully avoiding
         confusion for someone unfamiliar with the function of the
         attribute.
      
      2) Create a "driver" union within virDomainNetDef, and a "virtio"
         struct in that struct, which contains the "name" enum value.
      
      3) Move around the virDomainNetParse and virDomainNetFormat functions
         to allow for simple plugin of new attributes without disturbing
         existing code. (you'll note that this results in a seemingly
         redundant if() in the format function, but that will no longer be
         the case as soon as a 2nd attribute is added).
      
      In the future, new attributes for the virtio driver backend can be
      added to the "virtio" struct, and any other network device backend that
      needs an attribute will have its own struct added to the "driver"
      union.
      b670a412