1. 06 3月, 2012 15 次提交
    • L
      qemu: refactor hotplug detach of hostdevs · 93870c4e
      Laine Stump 提交于
      This refactoring is necessary to support hotplug detach of
      type=hostdev network devices, but needs to be in a separate patch to
      make potential debugging of regressions more practical.
      
      Rather than the lowest level functions searching for a matching
      device, the search is now done in the toplevel function, and an
      intermediate-level function (qemuDomainDetachThisHostDevice()), which
      expects that the device's entry is already found, is called (this
      intermediate function will be called by qemuDomainDetachNetDevice() in
      order to support detach of type=hostdev net devices)
      
      This patch should result in 0 differences in functionality.
      93870c4e
    • L
      qemu: re-order functions in qemu_hotplug.c · 6fbb957d
      Laine Stump 提交于
      Code movement only, no functional change. This is necessary to prevent
      a forward reference in an upcoming patch.
      6fbb957d
    • L
      conf: hostdev utility functions · cc5b1fe5
      Laine Stump 提交于
      Three new functions useful in other files:
      
      virDomainHostdevInsert:
      
      Add a new hostdev at the end of the array. This would more sensibly be
      called virDomainHostdevAppend, but the existing functions for other
      types of devices are called Insert.
      
      virDomainHostdevRemove:
      
      Eliminates one entry from the hostdevs array, but doesn't free it;
      patterned after the code at the end of the two
      qemuDomainDetachHostXXXDevice functions (and also other pre-existing
      virDomainXXXRemove functions for other device types).
      
      virDomainHostdevFind:
      
      This function is patterned from the search loops at the top of
      qemuDomainDetachHostPciDevice and qemuDomainDetachHostUsbDevice, and
      will be used to re-factor those (and other detach-related) functions.
      cc5b1fe5
    • L
      conf: put subsys part of virDomainHostdevDef into its own struct · 3175df88
      Laine Stump 提交于
      To shorten some new code that accesses the many fields within the
      subsys struct of a hostdev, create a separate toplevel, typedefed
      virDomainHostdevSubsys struct so that we can define temporary pointers
      to the subsys part.
      3175df88
    • L
      conf: give each hostdevdef a parent pointer · b973f920
      Laine Stump 提交于
      The parent can be any type of device. It defaults to type=none, and a
      NULL pointer. The intent is that if a hostdevdef is contained in the
      def for a higher level device (e.g. virDomainNetDef), hostdev->parent
      will point to the higher level device, and type will be set to that
      type of device. This way, during attach and detach of the device,
      parent can be checked, and appropriate callouts made to do higher
      level device initialization (e.g. setting MAC address).
      
      Also, although these hostdevs with parents will be added to a domain's
      hostdevs list, they will be treated slightly differently when
      traversing the list, e.g. virDomainHostdefDefFree for a hostdev that
      has a parent doesn't need to be called (and will be a NOP); it will
      simply be removed from the list (since the parent device object is in
      its own type-specific list, and will be freed from there).
      b973f920
    • L
      conf: HostdevDef parse/format helper functions · 5560170d
      Laine Stump 提交于
      In an upcoming patch, virDomainNetDef will acquire a
      virDomainHostdevDef, and the <interface> XML will take on some of the
      elements of a <hostdev>. To avoid duplicating the code for parsing and
      formatting the <source> element (which will be nearly identical in
      these two cases), this patch factors those parts out of the
      HostdevDef's parse and format functions, and puts them into separate
      helper functions that are now called by the HostdevDef
      parser/formatter, and will soon be called by the NetDef
      parser/formatter.
      
      One change in behavior - previously virDomainHostdevDefParseXML() had
      diverged from current common coding practice by logging an error and
      failing if it found any subelements of <hostdev> other than those it
      understood (standard libvirt practice is to ignore/discard unknown
      elements and attributes during parse). The new helper function ignores
      unknown elements, and thus so does the new
      virDomainHostdevDefParseXML.
      5560170d
    • L
      conf: make hostdev info a separate object · 29293930
      Laine Stump 提交于
      In order to allow for a virDomainHostdevDef that uses the
      virDomainDeviceInfo of a "higher level" device (such as a
      virDomainNetDef), this patch changes the virDomainDeviceInfo in the
      HostdevDef into a virDomainDeviceInfoPtr. Rather than adding checks
      all over the code to check for a null info, we just guarantee that it
      is always valid. The new function virDomainHostdevDefAlloc() allocates
      a virDomainDeviceInfo and plugs it in, and virDomainHostdevDefFree()
      makes sure it is freed.
      
      There were 4 places allocating virDomainHostdevDefs, all of them
      parsers of one sort or another, and those have all had their
      VIR_ALLOC(hostdev) changed to virDomainHostdevDefAlloc(). Other than
      that, and the new functions, all the rest of the changes are just
      mechanical removals of "&" or changing "." to "->".
      29293930
    • L
      conf: add device pointer to args of virDomainDeviceInfoIterate callback · 2f925c65
      Laine Stump 提交于
      There will be cases where the iterator callback will need to know the
      type of the device whose info is being operated on, and possibly even
      need to use some of the device's config. This patch adds a
      virDomainDeviceDefPtr to the args of every callback, and fills it in
      appropriately as the devices are iterated through.
      2f925c65
    • L
      qemu: rename virDomainDeviceInfoPtr variables to avoid confusion · 37038d5c
      Laine Stump 提交于
      The virDomainDeviceInfoPtrs in qemuCollectPCIAddress and
      qemuComparePCIDevice are named "dev" and "dev1", but those functions
      will be changed (in order to match a change in the args sent to
      virDomainDeviceInfoIterate() callback args) to contain a
      virDomainDeviceDefPtr device.
      
      This patch renames "dev" to "info" (and "dev[n]" to "info[n]") to
      avoid later confusion.
      37038d5c
    • L
      conf: reorder static functions in domain_conf.c · fdad9c34
      Laine Stump 提交于
      No code change, movement only.  This is necessary to eliminate forward
      references.
      fdad9c34
    • L
      conf: relocate virDomainDeviceDef and virDomainHostdevDef · 4ec60dfb
      Laine Stump 提交于
      This patch is only code movement + adding some forward definitions of
      typedefs.
      
      virDomainHostdevDef (not just a pointer to it, but an actual object)
      will be needed in virDomainNetDef and virDomainActualNetDef, so it
      must be relocated earlier in the file.
      
      Likewise, virDomainDeviceDef will be needed in virDomainHostdevDef, so
      it must be moved up even earlier. This, in turn, creates a forward
      reference problem, but fortunately only with pointers to other device
      types, so their typedefs can be moved up in the file, eliminating the
      problem.
      4ec60dfb
    • L
      conf: add missing device types to virDomainDevice(Type|Def) · 9890b318
      Laine Stump 提交于
      Not all device types were represented in virDomainDeviceType, so some
      types of devices couldn't be represented in a virDomainDeviceDef
      (which requires a different type of pointer in the union for each
      different kind of device).
      
      Since serial, parallel, channel, and console devices are all
      virDomainChrDef, and the virDomainDeviceType is never used to produce
      a string from the type (and only used in the other direction
      internally to code, never to produce XML), I only added one "CHR"
      type, which is associated with "virDomainChrDefPtr chr" in the union.
      9890b318
    • J
      Fix build after commit e3ba4025 · 118cfc25
      Jim Fehlig 提交于
      Commit e3ba4025 introduced a few build errors with HAVE_LIBNL undefined.
      118cfc25
    • L
      util: eliminate crash in virNetDevMacVLanCreateWithVPortProfile · d2a9d55f
      Laine Stump 提交于
      Commit 723d5c (added after the release of 0.9.10) adds a
      NetlinkEventClient for each interface sent to
      virNetDevMacVLanCreateWithVPortProfile. This should only be done if
      the interface actually *has* a virtPortProfile, otherwise the event
      handler would be a NOP. The bigger problem is that part of the setup
      to create the NetlinkEventClient is to do a memcpy of virtPortProfile
      - if it's NULL, this triggers a segv.
      
      This patch just qualifies the code that adds the client - if
      virtPortProfile is NULL, it's skipped.
      d2a9d55f
    • E
      blockResize: add flag for bytes · 877fd769
      Eric Blake 提交于
      Qemu supports sizing by bytes; we shouldn't force the user to
      round up if they really wanted an unaligned total size.
      
      * include/libvirt/libvirt.h.in (VIR_DOMAIN_BLOCK_RESIZE_BYTES):
      New flag.
      * src/libvirt.c (virDomainBlockResize): Document it.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockResize): Take
      size in bytes.
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextBlockResize):
      Likewise.  Pass bytes, not megabytes, to monitor.
      * src/qemu/qemu_driver.c (qemuDomainBlockResize): Implement new
      flag.
      877fd769
  2. 05 3月, 2012 7 次提交
    • J
      qemu: Shared or readonly disks are always safe wrt migration · 07dd6fb6
      Jiri Denemark 提交于
      No matter what cache mode is used, readonly disks are always safe wrt
      migration. Shared disks are required to be readonly or to disable
      host-side cache, which makes them safe as well.
      07dd6fb6
    • P
      libvirt-guests: Add parallel startup and shutdown of guests · 6c3642e9
      Peter Krempa 提交于
      With this patch, it's possible to shut down guests in parallel. Parallel
      startup was possible before, but this functionality was not documented
      properly.
      
      To enable parallel startup set the START_DELAY to 0.
      
      Parallel shutdown has a configurable parameter PARALLEL_SHUTDOWN that
      defines the number of machines being shut down in parallel. Enabling
      this feature changes the semantics of SHUTDOWN_TIMEOUT parameter that is
      applied as a cumulative timeout to shutdown all guests on a URI.
      6c3642e9
    • J
      rpc: Fix client crash on connection close · 720bee30
      Jiri Denemark 提交于
      A multi-threaded client with event loop may crash if one of its threads
      closes a connection while event loop is in the middle of sending
      keep-alive message (either request or response). The right place for it
      is inside virNetClientIOEventLoop() between poll() and
      virNetClientLock(). We should only close a connection directly if no-one
      is using it and defer the closing to the last user otherwise. So far we
      only did so if the close was initiated by keep-alive timeout.
      720bee30
    • J
      build: Fix build with dtrace + apparmor · 57e677a7
      Jiri Denemark 提交于
      Building virt-aa-helper with dtrace probes enabled, ldd complained about
      undefined references:
      
      ./.libs/libvirt_util.a(libvirt_util_la-event_poll.o):(.note.stapsdt+0x24):
      undefined reference to `libvirt_event_poll_purge_timeout_semaphore'
      ...
      57e677a7
    • O
      Fix type and add missed comment for diskChange callback · 3d2da30e
      Osier Yang 提交于
      Comment for parameter devAlias is missed. And a typo should
      be caused by copy & paste.
      3d2da30e
    • O
      qemu: Fix indention · 1f77472d
      Osier Yang 提交于
      1f77472d
    • P
      cpu: Add new flag supported by qemu to the cpu definition · d2c28911
      Peter Krempa 提交于
      Some new cpu features were added to qemu. This patch adds some of them
      to our CPU map.
      d2c28911
  3. 03 3月, 2012 3 次提交
    • Z
      Correct a check for capacity arg of storageVolumeResize() · 4f3287a4
      Zeeshan Ali (Khattak) 提交于
      Lets say I got a volume with '1G' allocation and '10G' capacity. The
      available space in the parent pool is '5G'. With the current check for
      overcapacity, I can only try to resize to <= '6G'. You see the problem?
      4f3287a4
    • L
      util: combine bools in virNetDevTapCreateInBridgePort into flags · d1c31023
      Laine Stump 提交于
      With an additional new bool added to determine whether or not to
      discourage the use of the supplied MAC address by the bridge itself,
      virNetDevTapCreateInBridgePort had three booleans (well, 2 bools and
      an int used as a bool) in the arg list, which made it increasingly
      difficult to follow what was going on. This patch combines those three
      into a single flags arg, which not only shortens the arg list, but
      makes it more self-documenting.
      d1c31023
    • A
      util: centralize tap device MAC address 1st byte "0xFE" modification · c1b164d7
      Ansis Atteka 提交于
      When a tap device for a domain is created and attached to a bridge,
      the first byte of the tap device MAC address is set to 0xFE, while the
      rest is set to match the MAC address that will be presented to the
      guest as its network device MAC address. Setting this high value in
      the tap's MAC address discourages the bridge from using the tap
      device's MAC address as the bridge's own MAC address (Linux bridges
      always take on the lowest numbered MAC address of all attached devices
      as their own).
      
      In one case within libvirt, a tap device is created and attached to
      the bridge with the intent that its MAC address be taken on by the
      bridge as its own (this is used to assure that the bridge has a fixed
      MAC address to prevent network outages created by the bridge MAC
      address "flapping" as guests are started and stopped). In this case,
      the first byte of the mac address is *not* altered to 0xFE.
      
      In the current code, callers to virNetDevTapCreateInBridgePort each
      make the MAC address modification themselves before calling, which
      leads to code duplication, and also prevents lower level functions
      from knowing the real MAC address being used by the guest. The problem
      here is that openvswitch bridges must be informed about this MAC
      address, or they will be unable to pass traffic to/from the guest.
      
      This patch centralizes the location of the MAC address "0xFE fixup"
      into virNetDevTapCreateInBridgePort(), meaning 1) callers of this
      function no longer need the extra strange bit of code, and 2)
      bitNetDevTapCreateBridgeInPort itself now is called with the guest's
      unaltered MAC address, and can pass it on, unmodified, to
      virNetDevOpenvswitchAddPort.
      
      There is no other behavioral change created by this patch.
      c1b164d7
  4. 02 3月, 2012 6 次提交
    • P
      daemon: Remove deprecated HAL from init script dependencies · 2dcca3ec
      Peter Krempa 提交于
      The init script for the daemon requests to start HAL although it has
      been deprecated long time ago. This patch removes the dependency.
      2dcca3ec
    • E
      build: fix output of pid values · 355ec281
      Eric Blake 提交于
      Nuke the last vestiges of printing pid_t values with the wrong
      types, at least in code compiled on mingw64.  There may be other
      places, but for now they are only compiled on systems where the
      existing %d doesn't trigger gcc warnings.
      
      * src/rpc/virnetsocket.c (virNetSocketNew): Use %lld and casting,
      rather than assuming any particular int type for pid_t.
      * src/util/command.c (virCommandRunAsync, virPidWait)
      (virPidAbort): Likewise.
      (verify): Drop a now stale assertion.
      355ec281
    • E
      build: use correct type for pid and similar types · 3e2c3d8f
      Eric Blake 提交于
      No thanks to 64-bit windows, with 64-bit pid_t, we have to avoid
      constructs like 'int pid'.  Our API in libvirt-qemu cannot be
      changed without breaking ABI; but then again, libvirt-qemu can
      only be used on systems that support UNIX sockets, which rules
      out Windows (even if qemu could be compiled there) - so for all
      points on the call chain that interact with this API decision,
      we require a different variable name to make it clear that we
      audited the use for safety.
      
      Adding a syntax-check rule only solves half the battle; anywhere
      that uses printf on a pid_t still needs to be converted, but that
      will be a separate patch.
      
      * cfg.mk (sc_correct_id_types): New syntax check.
      * src/libvirt-qemu.c (virDomainQemuAttach): Document why we didn't
      use pid_t for pid, and validate for overflow.
      * include/libvirt/libvirt-qemu.h (virDomainQemuAttach): Tweak name
      for syntax check.
      * src/vmware/vmware_conf.c (vmwareExtractPid): Likewise.
      * src/driver.h (virDrvDomainQemuAttach): Likewise.
      * tools/virsh.c (cmdQemuAttach): Likewise.
      * src/remote/qemu_protocol.x (qemu_domain_attach_args): Likewise.
      * src/qemu_protocol-structs (qemu_domain_attach_args): Likewise.
      * src/util/cgroup.c (virCgroupPidCode, virCgroupKillInternal):
      Likewise.
      * src/qemu/qemu_command.c(qemuParseProcFileStrings): Likewise.
      (qemuParseCommandLinePid): Use pid_t for pid.
      * daemon/libvirtd.c (daemonForkIntoBackground): Likewise.
      * src/conf/domain_conf.h (_virDomainObj): Likewise.
      * src/probes.d (rpc_socket_new): Likewise.
      * src/qemu/qemu_command.h (qemuParseCommandLinePid): Likewise.
      * src/qemu/qemu_driver.c (qemudGetProcessInfo, qemuDomainAttach):
      Likewise.
      * src/qemu/qemu_process.c (qemuProcessAttach): Likewise.
      * src/qemu/qemu_process.h (qemuProcessAttach): Likewise.
      * src/uml/uml_driver.c (umlGetProcessInfo): Likewise.
      * src/util/virnetdev.h (virNetDevSetNamespace): Likewise.
      * src/util/virnetdev.c (virNetDevSetNamespace): Likewise.
      * tests/testutils.c (virtTestCaptureProgramOutput): Likewise.
      * src/conf/storage_conf.h (_virStoragePerms): Use mode_t, uid_t,
      and gid_t rather than int.
      * src/security/security_dac.c (virSecurityDACSetOwnership): Likewise.
      * src/conf/storage_conf.c (virStorageDefParsePerms): Avoid
      compiler warning.
      3e2c3d8f
    • E
      build: prohibit cross-inclusion · 5c3a1564
      Eric Blake 提交于
      Make it easier to detect invalid cross-directory includes, by
      adding a syntax check.  The check is designed to be extensible:
      the default case lists only the non-driver directories, and
      specific directories can list a different set (for example,
      util/ can only use itself, network/ can only use itself, util/,
      or conf/).
      
      * .gnulib: Update to latest, for syntax check improvment.
      * cfg.mk (sc_prohibit_cross_inclusion): New check.
      (sc_prohibit_strncmp, sc_libvirt_unmarked_diagnostics): Simplify.
      5c3a1564
    • H
      avoid global variable shadowed · 362077e7
      Hu Tao 提交于
      If "conf/domain_conf.h" included in file nodeinfo.c, gcc complains about
      a variable shadowing. fix it for potential further including of the file.
      
      ref: https://www.redhat.com/archives/libvir-list/2012-February/msg00955.html
      362077e7
    • L
      util: remove unneeded #include in virrandom.c · 3c30fbcd
      Laine Stump 提交于
      Commit 7c90026d added #include "conf/domain_conf.h" to
      util/virrandom.c. Fortunately it didn't actually use anything from
      domain_conf.h, since as far as I'm aware, files in util aren't allowed
      to reference anything in conf (although the opposite is allowed). So
      this #include is unnecessary.
      
      I verified it still compiles with the line removed, but have placed a
      one day moratorium on me doing any "trivial rule" pushes, so will
      wait for someone else to verify/ACK before pushing.
      3c30fbcd
  5. 01 3月, 2012 7 次提交
    • E
      virsh: expose partial pull · ff4c25ba
      Eric Blake 提交于
      Now virsh can call virDomainBlockRebase.
      
      * tools/virsh.c (cmdBlockPull): Add --base parameter.
      (blockJobImpl): Use it to expose BlockRebase API.
      * tools/virsh.pod (blockpull): Document it.
      ff4c25ba
    • E
      qemu: pass block pull backing file to monitor · 10ec36e2
      Eric Blake 提交于
      This actually wires up the new optional parameter to block_stream:
      http://wiki.qemu.org/Features/LiveBlockMigration/ImageStreamingAPI
      
      The error checking is still sparse, since libvirt must not use
      qemu-img or header probing on a qcow2 file in use by qemu to
      check if the backing file name is valid; so for now, libvirt is
      relying on qemu to diagnose an incorrect backing name.  Fixing this
      will require libvirt to track the entire backing file chain at the
      time qemu is started and keeps it updated with snapshot and pull
      operations.
      
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockJob): Add
      parameter, and update callers.
      * src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockJob): Update
      signature.
      * src/qemu/qemu_monitor.h (qemuMonitorBlockJob): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Update caller.
      * src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Likewise.
      10ec36e2
    • E
      qemu: require json for block jobs · 68a13005
      Eric Blake 提交于
      Block job commands are not part of upstream qemu until 1.1; and
      proper support of job completion and cancellation depends on being
      able to receive QMP events, which implies the JSON monitor.
      Additionally, some early versions of block job commands were
      backported to RHEL qemu, but these versions lacked asynchronous
      job cancellation and partial block pull, so there are several
      patches that will still be needed in this area of libvirt code
      to support both flavors of block job commands.
      
      Due to earlier patches in libvirt, we are guaranteed that all versions
      of qemu that support block job commands already require libvirt to
      use the JSON monitor.  That means that the text version of block jobs
      will not be used, and having to refactor two copies of the block job
      handlers makes no sense.  So instead, we delete the text handlers.
      
      * src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Drop text monitor
      support.
      * src/qemu/qemu_monitor_text.h (qemuMonitorTextBlockJob): Delete.
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextParseBlockJobOne)
      (qemuMonitorTextParseBlockJob, qemuMonitorTextBlockJob):
      Likewise.
      68a13005
    • L
      513fc057
    • L
      util: wrap virnetlink.c to 80 columns · e91be41e
      Laine Stump 提交于
      e91be41e
    • E
      build: update to latest gnulib · 47d05109
      Eric Blake 提交于
      It's been a while, and we're between releases, so now's as good
      a time as any to resync.  This also fixes a build-breaker on
      cygwin, where cygwin 1.7.11 introduced a header bug in <termios.h>.
      
      * .gnulib: Update to latest.
      * bootstrap: Resync.
      * cfg.mk (sc_prohibit_strncmp): Copy upstream changes to
      sc_prohibit_strcmp.
      47d05109
    • C
      Fix typo in domain XML documentation · df873c80
      Christophe Fergeau 提交于
      s/Modyfing/Modifying
      df873c80
  6. 29 2月, 2012 2 次提交