1. 14 5月, 2010 1 次提交
    • D
      Don't reset user/group/security label on shared filesystems during migrate · 02ddaddf
      Daniel P. Berrange 提交于
      When QEMU runs with its disk on NFS, and as a non-root user, the
      disk is chownd to that non-root user. When migration completes
      the last step is shutting down the QEMU on the source host. THis
      normally resets user/group/security label. This is bad when the
      VM was just migrated because the file is still in use on the dest
      host. It is thus neccessary to skip the reset step for any files
      found to be on a shared filesystem
      
      * src/libvirt_private.syms: Export virStorageFileIsSharedFS
      * src/util/storage_file.c, src/util/storage_file.h: Add a new
        method virStorageFileIsSharedFS() to determine if a file is
        on a shared filesystem (NFS, GFS, OCFS2, etc)
      * src/qemu/qemu_driver.c: Tell security driver not to reset
        disk labels on migration completion
      * src/qemu/qemu_security_dac.c, src/qemu/qemu_security_stacked.c,
        src/security/security_selinux.c, src/security/security_driver.h,
        src/security/security_apparmor.c: Add ability to skip disk
        restore step for files on shared filesystems.
      02ddaddf
  2. 30 4月, 2010 1 次提交
  3. 02 4月, 2010 1 次提交
    • L
      Allow domain disk images on root-squash NFS to coexist with security driver. · 8a7b4be5
      Laine Stump 提交于
      (suggested by Daniel Berrange, tested by Dan Kenigsberg)
      
      virStorageFileGetMetadata will fail for disk images that are stored on
      a root-squash NFS share that isn't world-readable.
      SELinuxSetSecurityImageLabel is called during the startup of every
      domain (as long as security_driver != "none"), and it will propogate
      the error from virStorageFileGetMetadata, causing the domain startup
      to fail. This is, however, a common scenario when qemu is run as a
      non-root user and the disk image is stored on NFS.
      
      Ignoring this failure (which doesn't matter in this case, since the
      next thing done by SELinuxSetSecurityImageLabel - setting the file
      context - will also fail (and that function already ignores failures
      due to root-squash NFS) will allow us to continue bringing up the
      domain. The result is that we don't need to disable the entire
      security driver just because a domain's disk image is stored on
      root-squashed NFS.
      8a7b4be5
  4. 22 3月, 2010 1 次提交
  5. 16 3月, 2010 1 次提交
  6. 05 3月, 2010 1 次提交
    • D
      Fix USB passthrough based on product/vendor · 09ed0729
      Daniel P. Berrange 提交于
      Changeset
      
        commit 5073aa99
        Author: Cole Robinson <crobinso@redhat.com>
        Date:   Mon Jan 11 11:40:46 2010 -0500
      
      Added support for product/vendor based passthrough, but it only
      worked at the security driver layer. The main guest XML config
      was not updated with the resolved bus/device ID. When the QEMU
      argv refactoring removed use of product/vendor, this then broke
      launching guests.
      
      THe solution is to move the product/vendor resolution up a layer
      into the QEMU driver. So the first thing QEMU does is resolve
      the product/vendor to a bus/device and updates the XML config
      with this info. The rest of the code, including security drivers
      and QEMU argv generated can now rely on bus/device always being
      set.
      
      * src/util/hostusb.c, src/util/hostusb.h: Split vendor/product
        resolution code out of usbGetDevice and into usbFindDevice.
        Add accessors for bus/device ID
      * src/security/virt-aa-helper.c, src/security/security_selinux.c,
        src/qemu/qemu_security_dac.c: Remove vendor/product from the
        usbGetDevice() calls
      * src/qemu/qemu_driver.c: Use usbFindDevice to resolve vendor/product
        into a bus/device ID
      09ed0729
  7. 10 2月, 2010 2 次提交
    • D
      Remove virConnectPtr from USB/PCI device iterators · ce71b865
      Daniel P. Berrange 提交于
      All callers now pass a NULL virConnectPtr into the USB/PCi device
      iterator functions. Therefore the virConnectPtr arg can now be
      removed from these functions
      
      * src/util/hostusb.h, src/util/hostusb.c: Remove virConnectPtr
        from usbDeviceFileIterate
      * src/util/pci.c, src/util/pci.h: Remove virConnectPtr arg from
        pciDeviceFileIterate
      * src/qemu/qemu_security_dac.c, src/security/security_selinux.c: Update
        to drop redundant virConnectPtr arg
      ce71b865
    • D
      Remove use of virConnectPtr from security driver APIs · d6126f76
      Daniel P. Berrange 提交于
      The virConnectPtr is no longer required for error reporting since
      that is recorded in a thread local. Remove use of virConnectPtr
      from all APIs in security_driver.{h,c} and update all callers to
      match
      d6126f76
  8. 09 2月, 2010 5 次提交
  9. 21 1月, 2010 2 次提交
    • D
      Refactor setup & cleanup of security labels in security driver · 0c0e0d02
      Daniel P. Berrange 提交于
      The current security driver architecture has the following
      split of logic
      
       * domainGenSecurityLabel
      
          Allocate the unique label for the domain about to be started
      
       * domainGetSecurityLabel
      
          Retrieve the current live security label for a process
      
       * domainSetSecurityLabel
      
          Apply the previously allocated label to the current process
          Setup all disk image / device labelling
      
       * domainRestoreSecurityLabel
      
          Restore the original disk image / device labelling.
          Release the unique label for the domain
      
      The 'domainSetSecurityLabel' method is special because it runs
      in the context of the child process between the fork + exec.
      
      This is require in order to set the process label. It is not
      required in order to label disks/devices though. Having the
      disk labelling code run in the child process limits what it
      can do.
      
      In particularly libvirtd would like to remember the current
      disk image label, and only change shared image labels for the
      first VM to start. This requires use & update of global state
      in the libvirtd daemon, and thus cannot run in the child
      process context.
      
      The solution is to split domainSetSecurityLabel into two parts,
      one applies process label, and the other handles disk image
      labelling. At the same time domainRestoreSecurityLabel is
      similarly split, just so that it matches the style. Thus the
      previous 4 methods are replaced by the following 6 new methods
      
       * domainGenSecurityLabel
      
          Allocate the unique label for the domain about to be started
          No actual change here.
      
       * domainReleaseSecurityLabel
      
         Release the unique label for the domain
      
       * domainGetSecurityProcessLabel
      
         Retrieve the current live security label for a process
         Merely renamed for clarity.
      
       * domainSetSecurityProcessLabel
      
         Apply the previously allocated label to the current process
      
       * domainRestoreSecurityAllLabel
      
          Restore the original disk image / device labelling.
      
       * domainSetSecurityAllLabel
      
          Setup all disk image / device labelling
      
      The SELinux and AppArmour drivers are then updated to comply with
      this new spec. Notice that the AppArmour driver was actually a
      little different. It was creating its profile for the disk image
      and device labels in the 'domainGenSecurityLabel' method, where as
      the SELinux driver did it in 'domainSetSecurityLabel'. With the
      new method split, we can have consistency, with both drivers doing
      that in the domainSetSecurityAllLabel method.
      
      NB, the AppArmour changes here haven't been compiled so may not
      build.
      0c0e0d02
    • D
      Make security drivers responsible for checking dynamic vs static labelling · 81fbb4cb
      Daniel P. Berrange 提交于
      The QEMU driver is doing 90% of the calls to check for static vs
      dynamic labelling. Except it is forgetting todo so in many places,
      in particular hotplug is mistakenly assigning disk labels. Move
      all this logic into the security drivers themselves, so the HV
      drivers don't have to think about it.
      
      * src/security/security_driver.h: Add virDomainObjPtr parameter
        to virSecurityDomainRestoreHostdevLabel and to
        virSecurityDomainRestoreSavedStateLabel
      * src/security/security_selinux.c, src/security/security_apparmor.c:
        Add explicit checks for VIR_DOMAIN_SECLABEL_STATIC and skip all
        chcon() code in those cases
      * src/qemu/qemu_driver.c: Remove all checks for VIR_DOMAIN_SECLABEL_STATIC
        or VIR_DOMAIN_SECLABEL_DYNAMIC. Add missing checks for possibly NULL
        driver entry points.
      81fbb4cb
  10. 14 1月, 2010 1 次提交
    • C
      Implement path lookup for USB by vendor:product · 5073aa99
      Cole Robinson 提交于
      Based off how QEMU does it, look through /sys/bus/usb/devices/* for
      matching vendor:product info, and if found, use info from the surrounding
      files to build the device's /dev/bus/usb path.
      
      This fixes USB device assignment by vendor:product when running qemu
      as non-root (well, it should, but for some reason I couldn't reproduce
      the failure people are seeing in [1], but it appears to work properly)
      
      [1] https://bugzilla.redhat.com/show_bug.cgi?id=542450
      5073aa99
  11. 10 12月, 2009 1 次提交
    • M
      Add virBufferFreeAndReset() and replace free() · 1b9d0744
      Matthias Bolte 提交于
      Replace free(virBufferContentAndReset()) with virBufferFreeAndReset().
      Update documentation and replace all remaining calls to free() with
      calls to VIR_FREE(). Also add missing calls to virBufferFreeAndReset()
      and virReportOOMError() in OOM error cases.
      1b9d0744
  12. 23 11月, 2009 1 次提交
    • D
      Support QEMU's virtual FAT block device driver · e7c78b0a
      Daniel P. Berrange 提交于
      Introduce a new type="dir"  mode for <disks> that allows use of
      QEMU's  virtual FAT block device driver. eg
      
          <disk type='dir' device='floppy'>
            <source dir='/tmp/test'/>
            <target dev='fda' bus='fdc'/>
            <readonly/>
          </disk>
      
      gets turned into
      
        -drive file=fat:floppy:/tmp/test,if=floppy,index=0
      
      Only read-only disks are supported with virtual FAT mode
      
      * src/conf/domain_conf.c, src/conf/domain_conf.h: Add type="dir"
      * docs/schemas/domain.rng: Document new disk type
      * src/xen/xend_internal.c, src/xen/xm_internal.c: Raise error for
        unsupported disk types
      * tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args: Fix
        empty disk file handling
      * tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fat.args,
        tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fat.xml,
        tests/qemuxml2argvdata/qemuxml2argv-floppy-drive-fat.args,
        tests/qemuxml2argvdata/qemuxml2argv-floppy-drive-fat.xml
        tests/qemuxml2argvtest.c: Test QEMU vitual FAT driver
      * src/qemu/qemu_conf.c: Support generating fat:/some/dir type
        disk args
      * src/security/security_selinux.c: Temporarily skip labelling
        of directory based disks
      e7c78b0a
  13. 11 11月, 2009 1 次提交
    • D
      Fix save and restore with non-privileged guests and SELinux · bc0010b3
      Daniel P. Berrange 提交于
      When running qemu:///system instance, libvirtd runs as root,
      but QEMU may optionally be configured to run non-root. When
      then saving a guest to a state file, the file is initially
      created as root, and thus QEMU cannot write to it. It is also
      missing labelling required to allow access via SELinux.
      
      * src/qemu/qemu_driver.c: Set ownership on save image before
        running migrate command in virDomainSave impl. Call out to
        security driver to set save image labelling
      * src/security/security_driver.h: Add driver APIs for setting
        and restoring saved state file labelling
      * src/security/security_selinux.c: Implement saved state file
        labelling for SELinux
      bc0010b3
  14. 04 11月, 2009 1 次提交
    • C
      Various error reporting fixes · 4c44cdcc
      Cole Robinson 提交于
      - Don't duplicate SystemError
      - Use proper error code in domain_conf
      - Fix a broken error call in qemu_conf
      - Don't use VIR_ERR_ERROR in security driver (isn't a valid code in this case)
      4c44cdcc
  15. 03 11月, 2009 1 次提交
    • D
      Annotate many methods with ATTRIBUTE_RETURN_CHECK & fix problems · 46992453
      Daniel P. Berrange 提交于
      Nearly all of the methods in src/util/util.h have error codes that
      must be checked by the caller to correct detect & report failure.
      Add ATTRIBUTE_RETURN_CHECK to ensure compile time validation of
      this
      
      * daemon/libvirtd.c: Add explicit check on return value of virAsprintf
      * src/conf/domain_conf.c: Add missing check on virParseMacAddr return
        value status & report error
      * src/network/bridge_driver.c: Add missing OOM check on virAsprintf
        and report error
      * src/qemu/qemu_conf.c: Add missing check on virParseMacAddr return
        value status & report error
      * src/security/security_selinux.c: Remove call to virRandomInitialize
        that's done in libvirt.c already
      * src/storage/storage_backend_logical.c: Add check & log on virRun
        return status
      * src/util/util.c: Add missing checks on virAsprintf/Run status
      * src/util/util.h: Annotate all methods with ATTRIBUTE_RETURN_CHECK
        if they return an error status code
      * src/vbox/vbox_tmpl.c: Add missing check on virParseMacAddr
      * src/xen/xm_internal.c: Add missing checks on virAsprintf
      * tests/qemuargv2xmltest.c: Remove bogus call to virRandomInitialize()
      46992453
  16. 07 10月, 2009 1 次提交
    • J
      Add a domain argument to SVirt *RestoreImageLabel · 709c37e9
      Jamie Strandboge 提交于
      When James Morris originally submitted his sVirt patches (as seen in
      libvirt 0.6.1), he did not require on disk labelling for
      virSecurityDomainRestoreImageLabel. A later commit[2] changed this
      behavior to assume on disk labelling, which halts implementations for
      path-based MAC systems such as AppArmor and TOMOYO where
      vm->def->seclabel is required to obtain the label.
      
      * src/security/security_driver.h src/qemu/qemu_driver.c
        src/security/security_selinux.c: adds the 'virDomainObjPtr vm'
        argument back to *RestoreImageLabel
      709c37e9
  17. 01 10月, 2009 1 次提交
    • M
      Fix USB device re-labelling · 1daea0c5
      Mark McLoughlin 提交于
      A simple misplaced break out of a switch results in:
      
        libvir: error : Failed to open file '/sys/bus/pci/devices/0000:00:54c./vendor': No such file or directory
        libvir: error : Failed to open file '/sys/bus/pci/devices/0000:00:54c./device': No such file or directory
        libvir: error : this function is not supported by the hypervisor: Failed to read product/vendor ID for 0000:00:54c.
      
      when trying to passthrough a USB host device to qemu.
      
      * src/security_selinux.c: fix a switch/break thinko
      1daea0c5
  18. 30 9月, 2009 2 次提交
  19. 21 9月, 2009 1 次提交
    • D
      Move security drivers to src/security/ · e56c6a83
      Daniel P. Berrange 提交于
      * src/Makefile.am, src/qemu/qemu_conf.h, src/qemu/qemu_driver.c,
        tests/seclabeltest.c: Adapt for changed paths
      * src/security.c: Rename to src/security/security_driver.c
      * src/security.h: Rename to src/security/security_driver.h
      * src/security_selinux.c, src/security_selinux.h: Move to src/security/
      e56c6a83
  20. 10 9月, 2009 2 次提交
  21. 21 8月, 2009 1 次提交
  22. 23 7月, 2009 1 次提交
  23. 03 7月, 2009 3 次提交
  24. 12 6月, 2009 1 次提交
  25. 03 4月, 2009 2 次提交
  26. 01 4月, 2009 1 次提交
  27. 17 3月, 2009 1 次提交
  28. 03 3月, 2009 2 次提交