1. 30 4月, 2013 13 次提交
    • L
      security driver: eliminate memory leaks in failure paths · ed12bbee
      Laine Stump 提交于
      If virPCIDeviceGetVFIOGroupDev() failed,
      virSecurity*(Set|Restore)HostdevLabel() would fail to free a
      virPCIDevice that had been allocated.
      
      These leaks were all introduced (by me) very recently, in commit
      f0bd70a9.
      ed12bbee
    • J
      libxl: Fix double-dispose of libxl domain config · 80f01915
      Jim Fehlig 提交于
      libxlBuildDomainConfig() was disposing the libxl_domain_config object
      on error, only to have it disposed again by libxlBuildDomainConfig()'s
      caller, which resulted in a segfault.  Leave disposing of the config
      object to it's owner.
      80f01915
    • M
      esx: Support virtualHW version 9 · e0eb672e
      Martin Kletzander 提交于
      We already support ESX 5.1, but virtualHW version used by such
      hypervisor [1] wasn't taken into account.
      
      [1] http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&externalId=1003746
      e0eb672e
    • M
      Fix typo in augeas comment · a6a10a52
      Martin Kletzander 提交于
      a6a10a52
    • E
      build: mark conditionally unused variables · b376dea9
      Eric Blake 提交于
      These fixes solve a compilation failure on FreeBSD:
      
      util/virnetdevtap.c: In function 'virNetDevTapGetName':
      util/virnetdevtap.c:56: warning: unused parameter 'tapfd' [-Wunused-parameter]
      util/virnetdevtap.c:56: warning: unused parameter 'ifname' [-Wunused-parameter]
      
      * src/util/virnetdevtap.c (virNetDevTapGetName): Add attributes
      when TUNGETIFF is not present.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b376dea9
    • J
      virsh: clarify vol-{down,up}load description · ce284bb5
      Ján Tomko 提交于
      Mention file/volume contents instead of just 'file'/'volume'.
      
      Also change Download->download in vol-download help,
      to be consistent with other volume commands.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=955537
      ce284bb5
    • J
      qemu: report an error if memballoon has wrong address type · 29bd350b
      Ján Tomko 提交于
      qemuBuildMemballoonDevStr returns NULL if memballoon doesn't have
      the right address type, but it doesn't report an error, leading to:
      error: An error occurred, but the cause is unknown
      
      Report a helpful error message instead, e.g.:
      error: XML error: memballoon unsupported with address type 'usb'
      29bd350b
    • J
      qemu: assign addresses when converting xml to native · 11fc1bea
      Ján Tomko 提交于
      This adds addresses to domxml-to-native output and chooses
      the correct virtio devices for ccw and s390 machines.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=957077
      11fc1bea
    • J
      virsh: fix incorrect argument errors for long options · 53531e16
      Ján Tomko 提交于
      For long options, print:
      * the option as specified by the user if it's unknown
      * the canonical long option if its argument is not
        a number (and should be)
      
      And for missing arguments, print both the short and
      the long option name.
      (Doing only one of those would require either parsing
      argv ourselves or let getopt print the errors, since
      we can't tell long and short options apart by optopt
      or longindex)
      
      https://bugzilla.redhat.com/show_bug.cgi?id=949373
      
      Unsupported long option:
      
      $ virsh --pm
      Before:
      error: unsupported option '-
      After:
      error: unsupported option '--pm'. See --help.
      
      Missing parameter:
      
      $ virsh --deb
      Before:
      error: option '-d' requires an argument
      After:
      error: option '-d'/'--debug' requires an argument
      
      $ virsh -rd
      Before:
      error: option '-d' requires an argument
      After:
      error: option '-d'/'--debug' requires an argument
      
      Non-numeric parameter:
      
      $ virsh --deb duck
      Before:
      error: option -d takes a numeric argument
      After:
      error: option --debug takes a numeric argument
      53531e16
    • P
      qemu: Error out if spice port autoallocation is requested, but disabled · eca3fdf7
      Peter Krempa 提交于
      When a user requests auto-allocation of the spice TLS port but spice TLS
      is disabled in qemu.conf, we start the machine and let qemu fail instead
      of erroring out sooner.
      
      Add an error message so that this doesn't happen.
      eca3fdf7
    • P
      network: Don't remove transient network if creating of config file fails · 8e918900
      Peter Krempa 提交于
      On the off-chance that creation of persistent configuration file would
      fail when defining a network that is already started as transient, the
      code would remove the transient data structure and thus the network.
      
      This patch changes the code so that in such case, the network is again
      marked as transient and left behind.
      8e918900
    • L
      qemu: put usb cgroup setup in common function · 811143c0
      Laine Stump 提交于
      The USB-specific cgroup setup had been inserted inline in
      qemuDomainAttachHostUsbDevice and qemuSetupCgroup, but now there is a
      common cgroup setup function called for all hostdevs, so it makes sens
      to put the usb-specific setup there and just rely on that function
      being called.
      
      The one thing I'm uncertain of here (and a reason for not pushing
      until after release) is that previously hostdev->missing was checked
      only when starting a domain (and cgroup setup for the device skipped
      if missing was true), but with this consolidation, it is now checked
      in the case of hotplug as well. I don't know if this will have any
      practical effect (does it make sense to hotplug a "missing" usb
      device?)
      811143c0
    • L
      qemu: add vfio devices to cgroup ACL when appropriate · 6e13860c
      Laine Stump 提交于
      PCIO device assignment using VFIO requires read/write access by the
      qemu process to /dev/vfio/vfio, and /dev/vfio/nn, where "nn" is the
      VFIO group number that the assigned device belongs to (and can be
      found with the function virPCIDeviceGetVFIOGroupDev)
      
      /dev/vfio/vfio can be accessible to any guest without danger
      (according to vfio developers), so it is added to the static ACL.
      
      The group device must be dynamically added to the cgroup ACL for each
      vfio hostdev in two places:
      
      1) for any devices in the persistent config when the domain is started
         (done during qemuSetupCgroup())
      
      2) at device attach time for any hotplug devices (done in
         qemuDomainAttachHostDevice)
      
      The group device must be removed from the ACL when a device it
      "hot-unplugged" (in qemuDomainDetachHostDevice())
      
      Note that USB devices are already doing their own cgroup setup and
      teardown in the hostdev-usb specific function. I chose to make the new
      functions generic and call them in a common location though. We can
      then move the USB-specific code (which is duplicated in two locations)
      to this single location. I'll be posting a followup patch to do that.
      6e13860c
  2. 29 4月, 2013 1 次提交
  3. 27 4月, 2013 9 次提交
    • J
      conf: add missing error on OOM · d0f7fd99
      Ján Tomko 提交于
      I removed it in 5c3d5b22 by accident.
      d0f7fd99
    • J
      qemu: prevent invalid reads in qemuAssignDevicePCISlots · 379e4bcc
      Ján Tomko 提交于
      Don't reserve slot 2 for video if the machine has no PCI buses.
      Error out when the user specifies a video device without
      a PCI address when there are no PCI buses.
      
      (This wouldn't work on a machine with no PCI bus anyway since
      we do add PCI addresses for video devices to the command line)
      379e4bcc
    • J
      qemu: don't always reserve PCI addresses for implicit controllers · 877bc089
      Ján Tomko 提交于
      In the past we automatically added a USB controller and assigned
      it a PCI address (0:0:1.2) even on machines without a PCI bus.
      This didn't break machines with no PCI bus  because the command
      line for it is just '-usb', with no mention of the PCI bus.
      
      The implicit IDE controller (reserved address 0:0:1.1) has
      no command line at all.
      
      Commit b33eb0dc removed the ability to reserve PCI addresses
      on machines without a PCI bus. This made them stop working,
      since there would always be the implicit USB controller.
      
      Skip the reservation of addresses for these controllers when
      there is no PCI bus, instead of failing.
      877bc089
    • L
      conf: remove extraneous _TYPE from driver backend enums · 19635f7d
      Laine Stump 提交于
      This isn't strictly speaking a bugfix, but I realized I'd gotten a bit
      too verbose when I chose the names for
      VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_*. This shortens them all a bit.
      19635f7d
    • L
      network: support <driver name='vfio'/> in network definitions · d64e114f
      Laine Stump 提交于
      I remembered to document this bit, but somehow forgot to implement it.
      
      This adds <driver name='kvm|vfio'/> as a subelement to the <forward>
      element of a network (this puts it parallel to the match between
      mode='hostdev' attribute in a network and type='hostdev' in an
      <interface>).
      
      Since it's already documented, only the parser, formatter, backend
      driver recognition (it just translates/moves the flag into the
      <interface> at the appropriate time), and a test case were needed.
      
      (I used a separate enum for the values both because the original is
      defined in domain_conf.h, which is unavailable from network_conf.h,
      and because in the future it's possible that we may want to support
      other non-hostdev oriented driver names in the network parser; this
      makes sure that one can be expanded without the other).
      d64e114f
    • P
      qemu: launch bridge helper from libvirtd · 2d80fbb1
      Paolo Bonzini 提交于
      <source type='bridge'> uses a helper application to do the necessary
      TUN/TAP setup to use an existing network bridge, thus letting
      unprivileged users use TUN/TAP interfaces.
      
      However, libvirt should be preventing QEMU from running any setuid
      programs at all, which would include this helper program.  From
      a security POV, any setuid helper needs to be run by libvirtd itself,
      not QEMU.
      
      This is what this patch does.  libvirt now invokes the setuid helper,
      gets the TAP fd and then passes it to QEMU in the normal manner.
      The path to the helper is specified in qemu.conf.
      
      As a small advantage, this adds a <target dev='tap0'/> element to the
      XML of an active domain using <interface type='bridge'>.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2d80fbb1
    • P
      virnetdevtap: add virNetDevTapGetName · 740d98a1
      Paolo Bonzini 提交于
      This will be used on a tap file descriptor returned by the bridge helper
      to populate the <target> element, because the helper does not provide
      the interface name.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      740d98a1
    • J
      qemu: don't assign a PCI address to 'none' USB controller · a12475bd
      Ján Tomko 提交于
      Adjust the usb-none test, since it gives the memballoon a lower PCI slot now.
      Add a test for 'none' controller on s390, which doesn't have PCI buses.
      a12475bd
    • B
      fix segfault during virsh save in pv guest · 91d1911c
      Bamvor Jian Zhang 提交于
      this patch fix the wrong sequence for fd and timeout register. the sequence
      was right in dfa1e1dd for fd register, but it changed in e0622ca2.
      in this patch, set priv, xl_priv in info and increase info->priv ref count
      before virEventAddHandle. if do this after virEventAddHandle, the fd
      callback or fd deregister maybe got the empty priv, xl_priv or wrong ref
      count.
      
      after apply this patch, test more than 100 rounds passed compare to fail
      within 3 rounds without this patch. each round includes define -> start ->
      destroy -> create -> suspend -> resume -> reboot -> shutdown -> save ->
      resotre -> dump -> destroy -> create -> setmem -> setvcpus -> destroy.
      Signed-off-by: NBamvor Jian Zhang <bjzhang@suse.com>
      91d1911c
  4. 26 4月, 2013 17 次提交
    • L
      qemu: set qemu process' RLIMIT_MEMLOCK when VFIO is used · 93958945
      Laine Stump 提交于
      VFIO requires all of the guest's memory and IO space to be lockable in
      RAM. The domain's max_balloon is the maximum amount of memory the
      domain can have (in KiB). We add a generous 1GiB to that for IO space
      (still much better than KVM device assignment, where the KVM module
      actually *ignores* the process limits and locks everything anyway),
      and convert from KiB to bytes.
      
      In the case of hotplug, we are changing the limit for the already
      existing qemu process (prlimit() is used under the hood), and for
      regular commandline additions of vfio devices, we schedule a call to
      setrlimit() that will happen after the qemu process is forked.
      93958945
    • L
      qemu: use new virCommandSetMax(Processes|Files) · 7bdf459d
      Laine Stump 提交于
      These were previously being set in a custom hook function, but now
      that virCommand directly supports setting them, we can eliminate that
      part of the hook and call the APIs directly.
      7bdf459d
    • L
      util: new virCommandSetMax(MemLock|Processes|Files) · 776d49f4
      Laine Stump 提交于
      This patch adds two sets of functions:
      
      1) lower level virProcessSet*() functions that will immediately set
      the RLIMIT_MEMLOCK. RLIMIT_NPROC, or RLIMIT_NOFILE of either the
      current process (using setrlimit()) or any other process (using
      prlimit()). "current process" is indicated by passing a 0 for pid.
      
      2) functions for virCommand* that will setup a virCommand object to
      set those limits at a later time just after it has forked a new
      process, but before it execs the new program.
      
      configure.ac has prlimit and setrlimit added to the list of functions
      to check for, and the low level functions log an "unsupported" error)
      on platforms that don't support those functions.
      776d49f4
    • D
      Do proper escaping of cgroup resource partitions · f3662737
      Daniel P. Berrange 提交于
      If a user cgroup name begins with "cgroup.", "_" or with any of
      the controllers from /proc/cgroups followed by a dot, then they
      need to be prefixed with a single underscore. eg if there is
      an object "cpu.service", then this would end up as "_cpu.service"
      in the cgroup filesystem tree, however, "waldo.service" would
      stay "waldo.service", at least as long as nobody comes up with
      a cgroup controller called "waldo".
      
      Since we require a '.XXXX' suffix on all partitions, there is
      no scope for clashing with the kernel 'tasks' and 'release_agent'
      files.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      f3662737
    • D
      Ensure all cgroup partitions have a suffix of ".partition" · 9ddfe7ee
      Daniel P. Berrange 提交于
      If the partition named passed in the XML does not already have
      a suffix, ensure it gets a '.partition' added to each component.
      The exceptions are /machine, /user and /system which do not need
      to have a suffix, since they are fixed partitions at the top
      level.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      9ddfe7ee
    • D
      Change VM cgroup suffix from '{lxc,qemu}.libvirt' to 'libvirt-{lxc,qemu}' · 824e86e7
      Daniel P. Berrange 提交于
      Recently we changed to create VM cgroups with the naming pattern
      $VMNAME.$DRIVER.libvirt. Following discussions with the systemd
      community it was decided that only having a single '.' in the
      names is preferrable. So this changes the naming scheme to be
      $VMNAME.libvirt-$DRIVER. eg for LXC 'mycontainer.libvirt-lxc' or
      for KVM 'myvm.libvirt-qemu'.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      824e86e7
    • S
      test: Add JSON test for query-tpm-types · 7e77f252
      Stefan Berger 提交于
      Add a test case for query-tpm-models QMP command.
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      7e77f252
    • E
      virsh: suppress aliases in group help · 117dc4cc
      Eric Blake 提交于
      'virsh help | grep nodedev-det' shows only nodedev-detach, but
      'virsh help nodedev | grep nodedev-det' also shows the old alias
      nodedev-dettach that we intentionally hid in commit af3f9aab.
      
      See also commit 787f4feb and this bug report:
      https://bugzilla.redhat.com/show_bug.cgi?id=956966
      
      * tools/virsh.c (vshCmdGrpHelp): Copy suppression of vshCmdHelp.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      117dc4cc
    • L
      security: update hostdev labelling functions for VFIO · f0bd70a9
      Laine Stump 提交于
      Legacy kvm style pci device assignment requires changes to the
      labelling of several sysfs files for each device, but for vfio device
      assignment, the only thing that needs to be relabelled/chowned is the
      "group" device for the group that contains the device to be assigned.
      f0bd70a9
    • L
      util: new function virPCIDeviceGetVFIOGroupDev · b210208f
      Laine Stump 提交于
      Given a virPCIDevice, this function returns the path for the device
      that controls the vfio group the device belongs to,
      e.g. "/dev/vfio/15".
      b210208f
    • L
      virsh: use new virNodeDeviceDetachFlags · d923f6c8
      Laine Stump 提交于
      The virsh nodedev-detach command has a new --driver option. If it's
      given virsh will attempt to use the new virNodeDeviceDetachFlags API
      instead of virNodeDeviceDettach. Validation of the driver name string
      is left to the hypervisor (qemu accepts "kvm" or "vfio". The only
      other hypervisor that implements these functions is xen, and it only
      accepts NULL).
      d923f6c8
    • L
      xen: implement virNodeDeviceDetachFlags backend · cad14a52
      Laine Stump 提交于
      This was the only hypervisor driver other than qemu that implemented
      virNodeDeviceDettach. It doesn't currently support multiple pci device
      assignment driver backends, but it is simple to plug in this new API,
      which will make it easier for Xen people to fill it in later when they
      decide to support VFIO (or whatever other) device assignment. Also it
      means that management applications will have the same API available to
      them for both hypervisors on any given version of libvirt.
      
      The only acceptable value for driverName in this case is NULL, since
      there is no alternate, and I'm not willing to pick a name for the
      default driver used by Xen.
      cad14a52
    • L
      qemu: implement virNodeDeviceDetachFlags backend · eaff1611
      Laine Stump 提交于
      The differences from virNodeDeviceDettach are very minor:
      
      1) Check that the flags are 0.
      
      2) Set the virPCIDevice's stubDriver according to the driverName that
         is passed in.
      
      3) Call virPCIDeviceDetach with a NULL stubDriver, indicating it
         should get the name of the stub driver from the virPCIDevice
         object.
      eaff1611
    • L
      hypervisor api: implement RPC calls for virNodeDeviceDetachFlags · cc875b83
      Laine Stump 提交于
      This requires a custom function for remoteNodeDeviceDetachFlags,
      because it is named *NodeDevice, but it goes through the hypervisor
      driver rather than nodedevice driver, and so it uses privateData
      instead of nodeDevicePrivateData. (It has to go through the hypervisor
      driver, because that is the driver that knows about the backend drivers
      that will perform the pci device assignment).
      cc875b83
    • L
      hypervisor api: new virNodeDeviceDetachFlags · 35394196
      Laine Stump 提交于
      The existing virNodeDeviceDettach() assumes that there is only a
      single PCI device assignment backend driver appropriate for any
      hypervisor. This is no longer true, as the qemu driver is getting
      support for PCI device assignment via VFIO. The new API
      virNodeDeviceDetachFlags adds a driverName arg that should be set to
      the exact same string set in a domain <hostdev>'s <driver name='x'/>
      element (i.e. "vfio", "kvm", or NULL for default). It also adds a
      flags arg for good measure (and because it's possible we may need it
      when we start dealing with VFIO's "device groups").
      35394196
    • L
      qemu: bind/unbind stub driver according to config <driver name='x'/> · cc0a9188
      Laine Stump 提交于
      If the config for a device has specified <driver name='vfio'/>,
      "backend" in the pci part of the hostdev object will be set to
      ..._VFIO. In this case, when creating a virPCIDevice set the
      stubDriver to "vfio-pci", otherwise set it to "pci-stub". We will rely
      on the lower levels to report an error if the vfio driver isn't
      loaded.
      
      The detach/attach functions in virpci.c will pay attention to the
      stubDriver setting in the device, and bind/unbind the appropriate
      driver when preparing hostdevs for the domain.
      
      Note that we don't yet attempt to do anything to mark active any other
      devices in the same vfio "group" as a single device that is being
      marked active. We do need to do that, but in order to get basic VFIO
      functionality testing sooner rather than later, initially we'll just
      live with more cryptic errors when someone tries to do that.
      cc0a9188
    • L
      pci: keep a stubDriver in each virPCIDevice · be64199e
      Laine Stump 提交于
      This can be set when the virPCIDevice is created and placed on a list,
      then used later when traversing the list to determine which stub
      driver to bind/unbind for managed devices.
      
      The existing Detach and Attach functions' signatures haven't been
      changed (they still accept a stub driver name in the arg list), but if
      the arg list has NULL for stub driver and one is available in the
      device's object, that will be used. (we may later deprecate and remove
      the arg from those functions).
      be64199e