1. 07 7月, 2011 4 次提交
    • L
      util: rename err_exit to cleanup in interface.c · de796a32
      Laine Stump 提交于
      This brings it in line with the recommendations in HACKING.
      de796a32
    • M
      sysinfo: delete unnecessary white space of sysinfo. · 107ee906
      Minoru Usui 提交于
        * Trim each element and delete null entry of sysinfo by
        virSkipSpacesBackwards().
      Signed-off-by: NMinoru Usui <usui@mxm.nes.nec.co.jp>
      107ee906
    • E
      util: add virTrimSpaces · 01374ec8
      Eric Blake 提交于
      The next patch wants to adjust an end pointer to trim trailing
      spaces but without modifying the underlying string, but a more
      generally useful ability to trim trailing spaces in place is
      also worth providing.
      
      * src/util/util.h (virTrimSpaces, virSkipSpacesBackwards): New
      prototypes.
      * src/util/util.c (virTrimSpaces, virSkipSpacesBackwards): New
      functions.
      * src/libvirt_private.syms (util.h): Export new functions.
      Inspired by a patch by Minoru Usui.
      01374ec8
    • E
      util: fix virSkipSpaces · 82162316
      Eric Blake 提交于
      Most clients of virSkipSpaces don't want to omit backslashes.
      Also, open-coding the list of spaces is not as nice as using
      c_isspace.
      
      * src/util/util.c (virSkipSpaces): Use c_isspace.
      (virSkipSpacesAndBackslash): New function.
      * src/util/util.h (virSkipSpacesAndBackslash): New prototype.
      * src/xen/xend_internal.c (sexpr_to_xend_topology): Update caller.
      * src/libvirt_private.syms (util.h): Export new function.
      82162316
  2. 06 7月, 2011 8 次提交
    • M
      Reduce code duplication in virFileMakePath(Helper) · cd9a4232
      Matthias Bolte 提交于
      Move stat and mkdir to virFileMakePathHelper.
      
      Also use the stat result to detect whether the existing path
      is a directory and set errno accordingly if it's not.
      cd9a4232
    • M
      apparmor: Finish incomplete renaming of relabel to norelabel · 2d2d6a01
      Matthias Bolte 提交于
      Commit 693eac38 was incomplete here.
      2d2d6a01
    • D
      Fix default value of security label 'relabel' attribute · 693eac38
      Daniel P. Berrange 提交于
      When no <seclabel> is present in the XML, the virDomainSeclabelDef
      struct is left as all zeros. Unfortunately, this means it gets setup
      as type=dynamic, with relabel=no, which is an illegal combination.
      
      Change the 'bool relabel' attribute in virDomainSeclabelDef to
      the inverse 'bool norelabel' so that the default initialization
      is sensible
      
      * src/conf/domain_conf.c, src/conf/domain_conf.h,
        src/security/security_apparmor.c, src/security/security_selinux.c:
        Replace 'relabel' with 'norelabel'
      693eac38
    • M
      Fix return value semantic of virFileMakePath · e123e1ee
      Matthias Bolte 提交于
      Some callers expected virFileMakePath to set errno, some expected
      it to return an errno value. Unify this to return 0 on success and
      -1 on error. Set errno to report detailed error information.
      
      Also optimize virFileMakePath if stat fails with an errno different
      from ENOENT.
      e123e1ee
    • M
      c7694e3e
    • G
      pci: initialize state values on reattach · 416814e6
      Guannan Ren 提交于
      add a new API pciDeviceReAttachInit() in pci.c to initialize state values for nodedev reattach
      
      Initialize three state value of device driver to 1. This is just for a new call to
      qemudNodeDeviceReAttach()
      416814e6
    • L
      qemu: check flags in qemuDomainGetXMLDesc · 834ce603
      Laine Stump 提交于
      Although most functions with flags check to verify no application is
      passing in flag bits that are currently undefined, for some reason
      this function wasn't.
      834ce603
    • L
      conf: fix domain parse flags · d3f7c7b1
      Laine Stump 提交于
      * Change all flags args from int to unsigned int
      
      * Allow passing flags in virDomainObjParseFile (and propogate those
        flags all the way down the call chain). Previously the flags were
        hardcoded (to VIR_DOMAIN_XML_INTERNAL_STATUS) several layers down
        the chain. Pass that value in at the one place that is currently
        calling virDomainObjParseFile.
      d3f7c7b1
  3. 05 7月, 2011 2 次提交
  4. 04 7月, 2011 12 次提交
    • D
      Allow for resource relabelling with static labels · 6321fd97
      Daniel P. Berrange 提交于
      Add a new attribute to the <seclabel> XML to allow resource
      relabelling to be enabled with static label usage.
      
        <seclabel model='selinux' type='static' relabel='yes'>
          <label>system_u:system_r:svirt_t:s0:c392,c662</label>
        </seclabel>
      
      * docs/schemas/domain.rng: Add relabel attribute
      * src/conf/domain_conf.c, src/conf/domain_conf.h: Parse
        the 'relabel' attribute
      * src/qemu/qemu_process.c: Unconditionally clear out the
        'imagelabel' attribute
      * src/security/security_apparmor.c: Skip based on 'relabel'
        attribute instead of label type
      * src/security/security_selinux.c: Skip based on 'relabel'
        attribute instead of label type and fill in <imagelabel>
        attribute if relabel is enabled.
      6321fd97
    • D
      Allow a base label to be specified in dynamic labelling mode · 4ebfc427
      Daniel P. Berrange 提交于
      Normally the dynamic labelling mode will always use a base
      label of 'svirt_t' for VMs. Introduce a <baselabel> field
      in the <seclabel> XML to allow this base label to be changed
      
      eg
      
         <seclabel type='dynamic' model='selinux'>
           <baselabel>system_u:object_r:virt_t:s0</baselabel>
         </seclabel>
      
      * docs/schemas/domain.rng: Add <baselabel>
      * src/conf/domain_conf.c, src/conf/domain_conf.h: Parsing
        of base label
      * src/qemu/qemu_process.c: Don't reset 'model' attribute if
        a base label is specified
      * src/security/security_apparmor.c: Refuse to support base label
      * src/security/security_selinux.c: Use 'baselabel' when generating
        label, if available
      4ebfc427
    • O
      storage: Do not override the exact error of createRawFile · 49826eda
      Osier Yang 提交于
      virStorageBackendCreateRaw: createRawFile already reported the
      exact error.
      
      Before the fix:
      
      error: Failed to create vol vol-create.img
      error: cannot create path '/var/lib/libvirt/images/vol-create.img': Unknown error 18446744073709551597
      
      After the fix:
      
      error: Failed to create vol vol-create.img
      error: cannot fill file '/var/lib/libvirt/images/vol-create.img': No space left on device
      49826eda
    • W
      initialize pointer to NULL · 1aa5f85b
      Wen Congyang 提交于
      cmd is not initialized to NULL, but we try to freed it if we
      meet some error.
      1aa5f85b
    • E
      storage: avoid crash on parse error · 5dc404b7
      Eric Blake 提交于
      Coverity detected that we could crash on bogus input.  Meanwhile,
      strtok_r is rather heavy compared to strchr.
      
      * src/storage/storage_backend_iscsi.c (virStorageBackendIQNFound):
        Check for parse failure, and use lighter-weight functions.
      5dc404b7
    • E
      vmware: avoid null deref on failed lookup · 222f6233
      Eric Blake 提交于
      * src/vmware/vmware_driver.c (vmwareDomainReboot): Check error
        before dereferencing memory.
      222f6233
    • E
      qemu: avoid null deref on low memory · 74d224fa
      Eric Blake 提交于
      Detected by Coverity.  qemuDomainEventQueue requires a non-NULL
      pointer; most callers silently drop the event if we encountered
      and OOM situation trying to create the event.
      
      * src/qemu/qemu_migration.c (qemuMigrationFinish): Check for OOM.
      74d224fa
    • E
      cgroup: silence coverity warning · 3f81f8e4
      Eric Blake 提交于
      Coverity noted that most clients reacted to failure to hash; but in
      a best-effort kill loop, we can ignore failure.
      
      * src/util/cgroup.c (virCgroupKillInternal): Ignore hash failure.
      3f81f8e4
    • E
      rpc: silence coverity warning · dd0c42ab
      Eric Blake 提交于
      Coverity noted that 4 out of 5 calls to virNetClientStreamRaiseError
      checked the return value.  This case expects a particular value, so
      warn if our expectations went wrong due to some bug elsewhere.
      
      * src/rpc/virnetclient.c (virNetClientCallDispatchStream): Warn on
        unexpected scenario.
      dd0c42ab
    • E
      qemu: silence coverity warnings · aaea56dc
      Eric Blake 提交于
      Coverity warns if the majority of callers check a function for
      errors, but a few don't; but in qemu_audit and qemu_domain, the
      choice to not check for failures was safe.  In qemu_command, the
      failure to generate a uuid can only occur on a bad pointer.
      
      * src/qemu/qemu_audit.c (qemuAuditCgroup): Ignore failure to get
        cgroup controller.
      * src/qemu/qemu_domain.c (qemuDomainObjEnterMonitor)
        (qemuDomainObjEnterMonitorWithDriver): Ignore failure to get
        timestamp.
      * src/qemu/qemu_command.c (qemuParseCommandLine): Check for error.
      aaea56dc
    • E
      rpc: avoid memory leak on error · 6e07f72e
      Eric Blake 提交于
      Detected by Coverity.  The leak is on an error path, but I'm not
      sure whether that path is likely to be triggered in practice.
      
      * src/rpc/virnetserverservice.c (virNetServerServiceAccept): Plug leak.
      6e07f72e
    • E
      rpc: fix logic bug · 2aa83b43
      Eric Blake 提交于
      Spotted by Coverity.  If we don't update tmp each time through
      the loop, then if the filter being removed was not the head of
      the list, we accidentally lose all filters prior to the one we
      wanted to remove.
      
      * src/rpc/virnetserverclient.c (virNetServerClientRemoveFilter):
          Don't lose unrelated filters.
      2aa83b43
  5. 02 7月, 2011 4 次提交
    • E
      pci: avoid memory leak on error · 95eaf7ba
      Eric Blake 提交于
      Detected by Coverity.  Some, but not all, error paths were clean;
      but they were repetitive so I refactored them.
      
      * src/util/pci.c (pciGetDevice): Plug leak.
      95eaf7ba
    • E
      interface: avoid memory leak on parse error · 9e8b7c15
      Eric Blake 提交于
      Detected by Coverity.  Unlikely to hit unless the file contents
      were corrupted.
      
      * src/util/interface.c (ifaceRestoreMacAddress): Plug leak.
      9e8b7c15
    • E
      util: choose whether to require micro in version strings · 8ce1afff
      Eric Blake 提交于
      To avoid regressions, we let callers specify whether to require a
      minor and micro version.  Callers that were parsing uname() output
      benefit from defaulting to 0, whereas callers that were parsing
      version strings from other sources should not change in behavior.
      
      * src/util/util.c (virParseVersionString): Allow caller to choose
      whether to fail if minor or micro is missing.
      * src/util/util.h (virParseVersionString): Update signature.
      * src/esx/esx_driver.c (esxGetVersion): Update callers.
      * src/lxc/lxc_driver.c (lxcVersion): Likewise.
      * src/openvz/openvz_conf.c (openvzExtractVersionInfo): Likewise.
      * src/uml/uml_driver.c (umlGetVersion): Likewise.
      * src/vbox/vbox_MSCOMGlue.c (vboxLookupVersionInRegistry):
      Likewise.
      * src/vbox/vbox_tmpl.c (vboxExtractVersion): Likewise.
      * src/vmware/vmware_conf.c (vmwareExtractVersion): Likewise.
      * src/xenapi/xenapi_driver.c (xenapiGetVersion): Likewise.
      Reported by Matthias Bolte.
      8ce1afff
    • E
      build: consistently use CFLAGS · 6ae3052c
      Eric Blake 提交于
      According to the automake manual, CPPFLAGS (aka INCLUDES, as spelled
      in automake 1.9.6) should only include -I, -D, and -U directives; more
      generic directives like -Wall belong in CFLAGS since they affect more
      phases of the build process.  Therefore, we should be sticking CFLAGS
      additions into a CFLAGS container, not a CPPFLAGS container.
      
      * src/Makefile.am (libvirt_driver_vmware_la_CFLAGS): Use AM_CFLAGS.
      (INCLUDES): Move CFLAGS items...
      (AM_CFLAGS): ...to their proper location.
      * python/Makefile.am (INCLUDES, AM_CFLAGS): Likewise.
      * tests/Makefile.am (INCLUDES, AM_CFLAGS): Likewise.
      (commandtest_CFLAGS, commandhelper_CFLAGS)
      (virnetmessagetest_CFLAGS, virnetsockettest_CFLAGS): Use AM_CFLAGS.
      6ae3052c
  6. 01 7月, 2011 10 次提交
    • S
      fix virParseVersionString with linux 3.0 · d42b749a
      Scott Moser 提交于
      linux 3.0 has no micro version number, and that is causing problems
      for virParseVersionString.  The patch below should allow for:
        major
        major.minor
        major.minor.micro
      
      If major or minor are not present they just default to zero.
      We found this in Ubuntu (https://bugs.launchpad.net/bugs/802977)
      d42b749a
    • E
      build: remove dead variables · 0ac385bd
      Eric Blake 提交于
      Detected by Coverity.  No real harm in leaving these, but fixing
      them cuts down on the noise for future analysis.
      
      * src/rpc/virnetserver.c (virNetServerAddService): Delete unused
      entry.
      * src/util/sysinfo.c (virSysinfoRead): Delete dead assignment to
      base.
      0ac385bd
    • E
      build: simplify sanlock distribution · bf8fba1e
      Eric Blake 提交于
      EXTRA_DIST files should unconditionally be part of the tarball,
      rather than depending on the presence of sanlock-devel.
      
      Meanwhile, parallel builds could fail if we don't use mkdir -p.
      
      * src/Makefile.am (EXTRA_DIST): Always ship sanlock .aug and
      template .conf files.
      (%-sanlock.conf): Use MKDIR_P.
      bf8fba1e
    • E
      rpc: avoid freeing uninitialized variable · 0a8a79af
      Eric Blake 提交于
      Detected by Coverity.  Both are instances of bad things happening
      if pipe2 fails; the virNetClientNew failure could free garbage,
      and virNetSocketNewConnectCommand could close random fds.
      
      Note: POSIX doesn't guarantee the contents of fd[0] and fd[1]
      after pipe failure: http://austingroupbugs.net/view.php?id=467
      We may need to introduce a virPipe2 wrapper that guarantees
      that on pipe failure, the fds are explicitly set to -1, rather
      than our current state of assuming the fds are unchanged from
      their value prior to the failed pipe call.
      
      * src/rpc/virnetclient.c (virNetClientNew): Initialize variable.
      * src/rpc/virnetsocket.c (virNetSocketNewConnectCommand):
      Likewise.
      0a8a79af
    • D
      Fix stream procedure number for virDomainMigratePrepareTunnel3 · 1414cc5f
      Daniel P. Berrange 提交于
      The virDomainMigratePrepareTunnel3 impl in the remote driver
      was using the procedure number for the virDomainMigratePrepareTunnel
      method. This doesn't work out so well, because it makes the server
      ignore & drop all stream packets
      
      * src/remote/remote_driver.c: Fix procedure for PrepareTunnel3
      1414cc5f
    • D
      Send back an error if we get unexpected stream control message · cfd4370a
      Daniel P. Berrange 提交于
      We ignore any stream data packets which come in for streams which
      are not registered, since these packets are async and do not have
      a reply. If we get a stream control packet though we must send back
      an actual error, otherwise a (broken) client may hang forever
      making it hard to diagnose the client bug.
      
      * src/rpc/virnetserverprogram.c: Send back error for unexpected
        stream control messages
      cfd4370a
    • D
      Fix release of virNetMessagePtr instances in streams processing · c69ba670
      Daniel P. Berrange 提交于
      If a message packet for a invalid stream is received it is just
      free'd. This is not good because it doesn't let the client RPC
      request counter decrement. If a stream is shutdown with pending
      packets the message also isn't released properly because of an
      incorrect header type
      
      * daemon/stream.c: Fix message header type
      * src/rpc/virnetserverprogram.c: Send dummy reply instead of
        free'ing ignored stream message
      c69ba670
    • D
      Add missing include of signal.h in virnetsocket.c · f1c2c0e2
      Daniel P. Berrange 提交于
      virNetSocketFree uses kill(SIGTERM) so we must include
      signal.h for the definitions
      
      * src/rpc/virnetsocket.c: Include signal.h
      f1c2c0e2
    • D
      Fix potential crash when saving guests · e44bec2e
      Daniel P. Berrange 提交于
      The qemudDomainSaveFlag method will call EndJob on the 'vm'
      object it is passed in. This can result in the 'vm' object
      being free'd if the last reference is removed. Thus no caller
      of 'qemudDomainSaveFlag' must *ever* reference 'vm' again
      upon return.
      
      Unfortunately qemudDomainSave and qemuDomainManagedSave
      both call 'virDomainObjUnlock', which can result in a
      crash. This is non-deterministic since it involves a race
      with the monitor I/O thread.
      
      Fix this by making qemudDomainSaveFlag responsible for
      calling virDomainObjUnlock instead.
      
      * src/qemu/qemu_driver.c: Fix potential use after free
        when saving guests
      e44bec2e
    • D
      Fix uninitialized value in QEMU monitor FD sending code · f870c99b
      Daniel P. Berrange 提交于
      The 'char control[CMSG_SPACE(sizeof(int))];' was not being
      wiped, so could potentially contain uninitialized bytes.
      While this was harmless in this case, it caused complaints
      from valgrind
      
      * src/qemu/qemu_monitor.c: memset 'control' variable
        in qemuMonitorIOWriteWithFD
      f870c99b