1. 25 3月, 2011 1 次提交
    • E
      maint: prohibit access(,X_OK) · 391c397e
      Eric Blake 提交于
      This simplifies several callers that were repeating checks already
      guaranteed by util.c, and makes other callers more robust to now
      reject directories.  remote_driver.c was over-strict - access(,R_OK)
      is only needed to execute a script file; a binary only needs
      access(,X_OK) (besides, it's unusual to see a file with x but not
      r permissions, whether script or binary).
      
      * cfg.mk (sc_prohibit_access_xok): New syntax-check rule.
      (exclude_file_name_regexp--sc_prohibit_access_xok): Exempt one use.
      * src/network/bridge_driver.c (networkStartRadvd): Fix offenders.
      * src/qemu/qemu_capabilities.c (qemuCapsProbeMachineTypes)
      (qemuCapsInitGuest, qemuCapsInit, qemuCapsExtractVersionInfo):
      Likewise.
      * src/remote/remote_driver.c (remoteFindDaemonPath): Likewise.
      * src/uml/uml_driver.c (umlStartVMDaemon): Likewise.
      * src/util/hooks.c (virHookCheck): Likewise.
      391c397e
  2. 24 3月, 2011 1 次提交
    • W
      update domain status forcibly even if attach a device failed · 9450a7cb
      Wen Congyang 提交于
      Steps to reproduce this bug:
      1. virsh attach-disk domain --source diskimage --target sdb --sourcetype file --driver qemu --subdriver qcow2
         error: Failed to attach disk
         error: operation failed: adding scsi-disk,bus=scsi0.0,scsi-id=1,drive=drive-scsi0-0-1,id=scsi0-0-1 device failed: Property 'scsi-disk.drive' can't find value 'drive-scsi0-0-1'
      2. service libvirtd restart
         Stopping libvirtd daemon:                                  [  OK  ]
         Starting libvirtd daemon:                                  [  OK  ]
      3. virsh attach-disk domain --source diskimage --target sdb --sourcetype file --driver qemu --subdriver raw
         error: Failed to attach disk
         error: operation failed: adding lsi,id=scsi0,bus=pci.0,addr=0x6 device failed: Duplicate ID 'scsi0' for device
      
      The reason is that we create a new scsi controller but we do not update
      /var/run/libvirt/qemu/domain.xml.
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      9450a7cb
  3. 23 3月, 2011 2 次提交
    • W
      Initialization error of qemuCgroupData in Qemu host usb hotplug · bcac844f
      Wen Congyang 提交于
      Steps to reproduce this bug:
      # cat usb.xml
      <hostdev mode='subsystem' type='usb'>
        <source>
          <address bus='0x001' device='0x003'/>
        </source>
      </hostdev>
      # virsh attach-device vm1 usb.xml
      error: Failed to attach device from usb.xml
      error: server closed connection:
      
      The reason of this bug is that we set data.cgroup to NULL, and this will cause
      libvirtd crashed.
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      bcac844f
    • E
      qemu: simplify monitor callbacks · 18d68462
      Eric Blake 提交于
      A future patch will change reference counting idioms; consolidating
      this pattern now makes the next patch smaller (touch only the new
      macro rather than every caller).
      
      * src/qemu/qemu_monitor.c (QEMU_MONITOR_CALLBACK): New helper.
      (qemuMonitorGetDiskSecret, qemuMonitorEmitShutdown)
      (qemuMonitorEmitReset, qemuMonitorEmitPowerdown)
      (qemuMonitorEmitStop, qemuMonitorEmitRTCChange)
      (qemuMonitorEmitWatchdog, qemuMonitorEmitIOError)
      (qemuMonitorEmitGraphics): Use it to reduce duplication.
      18d68462
  4. 22 3月, 2011 9 次提交
    • D
      Wire up virDomainMigrateSetSpeed into QEMU driver · 83cc3d1d
      Daniel P. Berrange 提交于
      Enhance the QEMU migration monitoring loop, so that it can get
      a signal to change migration speed on the fly
      
      * src/qemu/qemu_domain.h: Add signal for changing speed on the fly
      * src/qemu/qemu_driver.c: Wire up virDomainMigrateSetSpeed driver
      * src/qemu/qemu_migration.c: Support signal for changing speed
      83cc3d1d
    • D
      Add public API for setting migration speed on the fly · cb4aba9b
      Daniel P. Berrange 提交于
      It is possible to set a migration speed limit when starting
      migration. This new API allows the speed limit to be changed
      on the fly to adjust to changing conditions
      
      * src/driver.h, src/libvirt.c, src/libvirt_public.syms,
        include/libvirt/libvirt.h.in: Add virDomainMigrateSetMaxSpeed
      * src/esx/esx_driver.c, src/lxc/lxc_driver.c,
        src/opennebula/one_driver.c, src/openvz/openvz_driver.c,
        src/phyp/phyp_driver.c, src/qemu/qemu_driver.c,
        src/remote/remote_driver.c, src/test/test_driver.c,
        src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
        src/vmware/vmware_driver.c, src/xen/xen_driver.c,
        src/libxl/libxl_driver.c: Stub new API
      cb4aba9b
    • H
      qemu: fallback to HMP drive_add/drive_del · c33ac2e3
      Hu Tao 提交于
      fallback to HMP drive_add/drive_del commands if not found in QMP
      c33ac2e3
    • J
      qemu: Only use HMP passthrough if it is supported · 24c56ceb
      Jiri Denemark 提交于
      Avoids calling text monitor methods when it is know they will not
      succeed and also results in nicer error messages.
      24c56ceb
    • J
      qemu: Detect support for HMP passthrough · abdfca09
      Jiri Denemark 提交于
      abdfca09
    • T
      qemu: add two hook script events "prepare" and "release" · 3415eeb5
      Thibault Vincent 提交于
      Fix for bug https://bugzilla.redhat.com/show_bug.cgi?id=618970
      
      The "prepare" hook is called very early in the VM statup process
      before device labeling, so that it can allocate ressources not
      managed by libvirt, such as DRBD, or for instance create missing
      bridges and vlan interfaces.
      * src/util/hooks.c src/util/hooks.h: add definitions for new hooks
        VIR_HOOK_QEMU_OP_PREPARE and VIR_HOOK_QEMU_OP_RELEASE
      * src/qemu/qemu_process.c: use them in qemuProcessStart and
        qemuProcessStop()
      3415eeb5
    • E
      qemu: simplify interface fd handling in monitor · a24ada4e
      Eric Blake 提交于
      With only a single caller to these two monitor commands, I
      didn't need to wrap a new WithFds version, but just change
      the command itself.
      
      * src/qemu/qemu_monitor.h (qemuMonitorAddNetdev)
      (qemuMonitorAddHostNetwork): Add parameters.
      * src/qemu/qemu_monitor.c (qemuMonitorAddNetdev)
      (qemuMonitorAddHostNetwork): Add support for fd passing.
      * src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Use it to
      simplify code.
      a24ada4e
    • E
      qemu: simplify PCI configfd handling in monitor · 09831239
      Eric Blake 提交于
      This is also a bug fix - on the error path, qemu_hotplug would
      leave the configfd file leaked into qemu.  At least the next
      attempt to hotplug a PCI device would reuse the same fdname,
      and when the qemu getfd monitor command gets a new fd by the
      same name as an earlier one, it closes the earlier one, so there
      is no risk of qemu running out of fds.
      
      * src/qemu/qemu_monitor.h (qemuMonitorAddDeviceWithFd): New
      prototype.
      * src/qemu/qemu_monitor.c (qemuMonitorAddDevice): Move guts...
      (qemuMonitorAddDeviceWithFd): ...to new function, and add support
      for fd passing.
      * src/qemu/qemu_hotplug.c (qemuDomainAttachHostPciDevice): Use it
      to simplify code.
      Suggested by Daniel P. Berrange.
      09831239
    • E
      qemu: simplify monitor fd error handling · 058d4efa
      Eric Blake 提交于
      qemu_monitor was already returning -1 and setting errno to EINVAL
      on any attempt to send an fd without a unix socket, but this was
      a silent failure in the case of qemuDomainAttachHostPciDevice.
      Meanwhile, qemuDomainAttachNetDevice was doing some sanity checking
      for a better error message; it's better to consolidate that to a
      central point in the API.
      
      * src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Move sanity
      checking...
      * src/qemu/qemu_monitor.c (qemuMonitorSendFileHandle): ...into
      central location.
      Suggested by Chris Wright.
      058d4efa
  5. 19 3月, 2011 1 次提交
    • E
      qemu: respect locking rules · 49608417
      Eric Blake 提交于
      THREADS.txt states that the contents of vm should not be read or
      modified while the vm lock is not held, but that the lock must not
      be held while performing a monitor command.  This fixes all the
      offenders that I could find.
      
      * src/qemu/qemu_process.c (qemuProcessStartCPUs)
      (qemuProcessInitPasswords, qemuProcessStart): Don't modify or
      refer to vm state outside lock.
      * src/qemu/qemu_driver.c (qemudDomainHotplugVcpus): Likewise.
      * src/qemu/qemu_hotplug.c (qemuDomainChangeGraphicsPasswords):
      Likewise.
      49608417
  6. 18 3月, 2011 5 次提交
    • J
      qemu: Fix copy&paste error messages in text monitor · c3ad755f
      Jiri Denemark 提交于
      c3ad755f
    • W
      do not unref obj in qemuDomainObjExitMonitor* · d5df67be
      Wen Congyang 提交于
      Steps to reproduce this bug:
      # cat test.sh
        #! /bin/bash -x
        virsh start domain
        sleep 5
        virsh qemu-monitor-command domain 'cpu_set 2 online' --hmp
      # while true; do ./test.sh ; done
      
      Then libvirtd will crash.
      
      The reason is that:
      we add a reference of obj when we open the monitor. We will reduce this
      reference when we free the monitor.
      
      If the reference of monitor is 0, we will free monitor automatically and
      the reference of obj is reduced.
      
      But in the function qemuDomainObjExitMonitorWithDriver(), we reduce this
      reference again when the reference of monitor is 0.
      
      It will cause the obj be freed in the function qemuDomainObjEndJob().
      
      Then we start the domain again, and libvirtd will crash in the function
      virDomainObjListSearchName(), because we pass a null pointer(obj->def->name)
      to strcmp().
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      d5df67be
    • W
      qemu: check driver name while attaching disk · e2aec53b
      Wen Congyang 提交于
      This bug was reported by Shi Jin(jinzishuai@gmail.com):
      =============
      # virsh attach-disk RHEL6RC /var/lib/libvirt/images/test3.img vdb \
              --driver file --subdriver qcow2
      Disk attached successfully
      
      # virsh save RHEL6RC /var/lib/libvirt/images/memory.save
      Domain RHEL6RC saved to /var/lib/libvirt/images/memory.save
      
      # virsh restore /var/lib/libvirt/images/memory.save
      error: Failed to restore domain from /var/lib/libvirt/images/memory.save
      error: internal error unsupported driver name 'file'
             for disk '/var/lib/libvirt/images/test3.img'
      =============
      
      We check the driver name when we start or restore VM, but we do
      not check it while attaching a disk. This adds the same check on disk
      driverName used in qemuBuildCommandLine to qemudDomainAttachDevice.
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      e2aec53b
    • W
      unlock the monitor when unwatching the monitor · 9741f346
      Wen Congyang 提交于
      Steps to reproduce this bug:
      # virsh qemu-monitor-command domain 'cpu_set 2 online' --hmp
      The domain has 2 cpus, and we try to set the third cpu online.
      The qemu crashes, and this command will hang.
      
      The reason is that the refs is not 1 when we unwatch the monitor.
      We lock the monitor, but we do not unlock it. So virCondWait()
      will be blocked.
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      9741f346
    • N
      virsh: fix memtune's help message for swap_hard_limit · 78ba748e
      Nikunj A. Dadhania 提交于
      * Correct the documentation for cgroup: the swap_hard_limit indicates
        mem+swap_hard_limit.
      * Change cgroup private apis to: virCgroupGet/SetMemSwapHardLimit
      Signed-off-by: NNikunj A. Dadhania <nikunj@linux.vnet.ibm.com>
      78ba748e
  7. 16 3月, 2011 2 次提交
    • E
      qemu: support migration to fd · 100bba06
      Eric Blake 提交于
      * src/qemu/qemu_monitor.h (qemuMonitorMigrateToFd): New
      prototype.
      * src/qemu/qemu_monitor.c (qemuMonitorMigrateToFd): New function.
      100bba06
    • E
      qemu: improve efficiency of dd during snapshots · 8e42c50b
      Eric Blake 提交于
      POSIX states about dd:
      
      If the bs=expr operand is specified and no conversions other than
      sync, noerror, or notrunc are requested, the data returned from each
      input block shall be written as a separate output block; if the read
      returns less than a full block and the sync conversion is not
      specified, the resulting output block shall be the same size as the
      input block. If the bs=expr operand is not specified, or a conversion
      other than sync, noerror, or notrunc is requested, the input shall be
      processed and collected into full-sized output blocks until the end of
      the input is reached.
      
      Since we aren't using conv=sync, there is no zero-padding, but our
      use of bs= means that a short read results in a short write.  If
      instead we use ibs= and obs=, then short reads are collected and dd
      only has to do a single write, which can make dd more efficient.
      
      * src/qemu/qemu_monitor.c (qemuMonitorMigrateToFile):
      Avoid 'dd bs=', since it can cause short writes.
      8e42c50b
  8. 15 3月, 2011 6 次提交
    • W
      ce81bc5c
    • E
      qemu: use more appropriate error · 30a50fc3
      Eric Blake 提交于
      Fixes bug in commit acacced8
      
      * src/qemu/qemu_command.c (qemuBuildCommandLine):
      s/INVALID_ARG/CONFIG_UNSUPPORTED/.
      Reported by Daniel P. Berrange.
      30a50fc3
    • E
      qemu: consolidate duplicated monitor migration code · 1c5dc4c6
      Eric Blake 提交于
      * src/qemu/qemu_monitor_text.h (qemuMonitorTextMigrate): Declare
      in place of individual monitor commands.
      * src/qemu/qemu_monitor_json.h (qemuMonitorJSONMigrate): Likewise.
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextMigrateToHost)
      (qemuMonitorTextMigrateToCommand, qemuMonitorTextMigrateToFile)
      (qemuMonitorTextMigrateToUnix): Delete.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONMigrateToHost)
      (qemuMonitorJSONMigrateToCommand, qemuMonitorJSONMigrateToFile)
      (qemuMonitorJSONMigrateToUnix): Delete.
      * src/qemu/qemu_monitor.c (qemuMonitorMigrateToHost)
      (qemuMonitorMigrateToCommand, qemuMonitorMigrateToFile)
      (qemuMonitorMigrateToUnix): Consolidate shared code.
      1c5dc4c6
    • E
      qemu: use lighter-weight fd:n on incoming tunneled migration · c7af07ac
      Eric Blake 提交于
      Outgoing migration still uses a Unix socket and or exec netcat until
      the next patch.
      
      * src/qemu/qemu_migration.c (qemuMigrationPrepareTunnel):
      Replace Unix socket with simpler pipe.
      Suggested by Paolo Bonzini.
      c7af07ac
    • O
      qemu: Check the unsigned integer overflow · acacced8
      Osier Yang 提交于
      As perhaps other hypervisor drivers use different capacity units,
      do the checking in qemu driver instead of in conf/domain_conf.c.
      acacced8
    • L
      audit: eliminate potential null pointer deref when auditing macvtap devices · 7cc101ce
      Laine Stump 提交于
      The newly added call to qemuAuditNetDevice in qemuPhysIfaceConnect was
      assuming that res_ifname (the name of the macvtap device) was always
      valid, but this isn't the case. If openMacvtapTap fails, it always
      returns NULL, which would result in a segv.
      
      Since the audit log only needs a record of devices that are actually
      sent to qemu, and a failure to open the macvtap device means that no
      device will be sent to qemu, we can solve this problem by only doing
      the audit if openMacvtapTap is successful (in which case res_ifname is
      guaranteed valid).
      7cc101ce
  9. 12 3月, 2011 1 次提交
  10. 11 3月, 2011 4 次提交
  11. 10 3月, 2011 8 次提交
    • E
      audit: audit use of /dev/net/tun, /dev/tapN, /dev/vhost-net · 9516a0ec
      Eric Blake 提交于
      Opening raw network devices with the intent of passing those fds to
      qemu is worth an audit point.  This makes a multi-part audit: first,
      we audit the device(s) that libvirt opens on behalf of the MAC address
      of a to-be-created interface (which can independently succeed or
      fail), then we audit whether qemu actually started the network device
      with the same MAC (so searching backwards for successful audits with
      the same MAC will show which fd(s) qemu is actually using).  Note that
      it is possible for the fd to be successfully opened but no attempt
      made to pass the fd to qemu (for example, because intermediate
      nwfilter operations failed) - no interface start audit will occur in
      that case; so the audit for a successful opened fd does not imply
      rights given to qemu unless there is a followup audit about the
      attempt to start a new interface.
      
      Likewise, when a network device is hot-unplugged, there is only one
      audit message about the MAC being discontinued; again, searching back
      to the earlier device open audits will show which fds that qemu quits
      using (and yes, I checked via /proc/<qemu-pid>/fd that qemu _does_
      close out the fds associated with an interface on hot-unplug).  The
      code would require much more refactoring to be able to definitively
      state which device(s) were discontinued at that point, since we
      currently don't record anywhere in the XML whether /dev/vhost-net was
      opened for a given interface.
      
      * src/qemu/qemu_audit.h (qemuAuditNetDevice): New prototype.
      * src/qemu/qemu_audit.c (qemuAuditNetDevice): New function.
      * src/qemu/qemu_command.h (qemuNetworkIfaceConnect)
      (qemuPhysIfaceConnect, qemuOpenVhostNet): Adjust prototype.
      * src/qemu/qemu_command.c (qemuNetworkIfaceConnect)
      (qemuPhysIfaceConnect, qemuOpenVhostNet): Add audit points and
      adjust parameters.
      (qemuBuildCommandLine): Adjust caller.
      * src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
      9516a0ec
    • E
      qemu: don't request cgroup ACL access for /dev/net/tun · c52cbe48
      Eric Blake 提交于
      Since libvirt always passes /dev/net/tun to qemu via fd, we should
      never trigger the cases where qemu tries to directly open the
      device.  Therefore, it is safer to deny the cgroup device ACL.
      
      * src/qemu/qemu_cgroup.c (defaultDeviceACL): Remove /dev/net/tun.
      * src/qemu/qemu.conf (cgroup_device_acl): Reflect this change.
      c52cbe48
    • E
      qemu: support vhost in attach-interface · 5d091513
      Eric Blake 提交于
      * src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Honor vhost
      designations, similar to qemu_command code paths.
      * src/qemu/qemu_command.h (qemuOpenVhostNet): New prototype.
      * src/qemu/qemu_command.c (qemuOpenVhostNet): Export.
      5d091513
    • J
      qemu: Stop guest CPUs before creating a snapshot · 346236fe
      Jiri Denemark 提交于
      346236fe
    • J
      qemu: Refactor qemuDomainSnapshotCreateXML · 89e75b01
      Jiri Denemark 提交于
      89e75b01
    • J
      81711cee
    • J
      qemu: Fallback to HMP for snapshot commands · 89241fe0
      Jiri Denemark 提交于
      qemu driver in libvirt gained support for creating domain snapshots
      almost a year ago in libvirt 0.8.0. Since then we enabled QMP support
      for qemu >= 0.13.0 but QMP equivalents of {save,load,del}vm commands are
      not implemented in current qemu (0.14.0) so the domain snapshot support
      is not very useful.
      
      This patch detects when the appropriate QMP command is not implemented
      and tries to use human-monitor-command (aka HMP passthrough) to run
      it's HMP equivalent.
      89241fe0
    • J
      qemu: Rename qemuMonitorCommandWithHandler as qemuMonitorText* · b3c6ec03
      Jiri Denemark 提交于
      To make it more obvious that it is only used for text monitor. The
      naming also matches the style of qemuMonitorTextCommandWithFd.
      b3c6ec03