[libvirt] [PATCH] util: Fix warning message in previous patch
by Peter Krempa
I didn't notice the extra "does" in the previous patch. Remove it.
---
My mistake. Pushed under trivial rule.
---
src/util/util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index 27af3c6..05e7ca7 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2536,7 +2536,7 @@ virGetUserIDByName(const char *name, uid_t *uid)
/* log the possible error from getpwnam_r. Unfortunately error
* reporting from this function is bad and we can't really
* rely on it, so we just report that the user wasn't found */
- VIR_WARN("User record for user '%s' does was not found: %s",
+ VIR_WARN("User record for user '%s' was not found: %s",
name, virStrerror(rc, buf, sizeof(buf)));
}
@@ -2620,7 +2620,7 @@ virGetGroupIDByName(const char *name, gid_t *gid)
/* log the possible error from getgrnam_r. Unfortunately error
* reporting from this function is bad and we can't really
* rely on it, so we just report that the user wasn't found */
- VIR_WARN("Group record for user '%s' does was not found: %s",
+ VIR_WARN("Group record for user '%s' was not found: %s",
name, virStrerror(rc, buf, sizeof(buf)));
}
--
1.8.0
12 years
[libvirt] [PATCH] Fix sorting of libvirt_private.syms and add syntax check rule
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Add check-symsorting.pl to perform case-insensitive alphabetical
sorting of groups of symbols. Fix all violations it reports
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/Makefile.am | 4 +-
src/check-symsorting.pl | 66 +++++++++++++++++++
src/libvirt_esx.syms | 2 +-
src/libvirt_openvz.syms | 2 +-
src/libvirt_private.syms | 161 ++++++++++++++++++++++++-----------------------
5 files changed, 152 insertions(+), 83 deletions(-)
create mode 100644 src/check-symsorting.pl
diff --git a/src/Makefile.am b/src/Makefile.am
index 6d2816d..7cb1d4a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -326,6 +326,8 @@ check-symfile: libvirt.syms libvirt.la
else
check-symfile:
endif
+check-symsorting:
+ $(AM_V_GEN)$(PERL) $(srcdir)/check-symsorting.pl $(USED_SYM_FILES)
PROTOCOL_STRUCTS = \
$(srcdir)/remote_protocol-structs \
@@ -349,7 +351,7 @@ else !WITH_REMOTE
check-protocol:
endif
EXTRA_DIST += $(PROTOCOL_STRUCTS) check-symfile.pl
-check-local: check-protocol check-symfile
+check-local: check-protocol check-symfile check-symsorting
.PHONY: check-protocol $(PROTOCOL_STRUCTS:structs=struct)
# Mock driver, covering domains, storage, networks, etc
diff --git a/src/check-symsorting.pl b/src/check-symsorting.pl
new file mode 100644
index 0000000..9c62246
--- /dev/null
+++ b/src/check-symsorting.pl
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+die "syntax: $0 SYMFILE..." unless int(@ARGV) >= 1;
+
+my $ret = 0;
+foreach my $symfile (@ARGV) {
+ open SYMFILE, $symfile or die "cannot read $symfile: $!";
+
+ my $line;
+ my @group;
+
+ while (<SYMFILE>) {
+ chomp;
+ next if /^#/;
+
+ if (/^\s*$/) {
+ if (@group) {
+ &check_sorting(\@group, $symfile, $line);
+ }
+ @group = ();
+ $line = $.;
+ } else {
+ $_ =~ s/;//;
+ push @group, $_;
+ }
+ }
+
+ close SYMFILE;
+ if (@group) {
+ &check_sorting(\@group, $symfile, $line);
+ }
+}
+
+sub check_sorting {
+ my $group = shift;
+ my $symfile = shift;
+ my $line = shift;
+
+ my @group = @{$group};
+ my @sorted = sort { lc $a cmp lc $b } @group;
+ my $sorted = 1;
+ my $first;
+ my $last;
+ for (my $i = 0 ; $i <= $#sorted ; $i++) {
+ if ($sorted[$i] ne $group[$i]) {
+ $first = $i unless defined $first;
+ $last = $i;
+ $sorted = 0;
+ }
+ }
+ if (!$sorted) {
+ @group = splice @group, $first, ($last-$first+1);
+ @sorted = splice @sorted, $first, ($last-$first+1);
+ print "Symbol block at $symfile:$line symbols not sorted\n";
+ print map { " " . $_ . "\n" } @group;
+ print "Correct ordering\n";
+ print map { " " . $_ . "\n" } @sorted;
+ print "\n";
+ $ret = 1;
+ }
+}
+
+exit $ret;
diff --git a/src/libvirt_esx.syms b/src/libvirt_esx.syms
index 3125b20..0341b66 100644
--- a/src/libvirt_esx.syms
+++ b/src/libvirt_esx.syms
@@ -3,5 +3,5 @@
#
esxUtil_EscapeDatastoreItem;
-esxVI_DateTime_ConvertToCalendarTime;
esxUtil_ParseDatastorePath;
+esxVI_DateTime_ConvertToCalendarTime;
diff --git a/src/libvirt_openvz.syms b/src/libvirt_openvz.syms
index 1993eb5..578d8b5 100644
--- a/src/libvirt_openvz.syms
+++ b/src/libvirt_openvz.syms
@@ -1,7 +1,7 @@
#
# These symbols are dependent upon --with-openvz via WITH_OPENVZ
#
+openvzLocateConfFile;
openvzReadConfigParam;
openvzReadNetworkConf;
-openvzLocateConfFile;
openvzVEGetStringParam;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7d083e4..1e34210 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -85,25 +85,25 @@ virCgroupDenyDeviceMajor;
virCgroupDenyDevicePath;
virCgroupForDomain;
virCgroupForDriver;
-virCgroupGetAppRoot;
virCgroupForEmulator;
virCgroupForVcpu;
virCgroupFree;
+virCgroupGetAppRoot;
virCgroupGetBlkioWeight;
-virCgroupGetCpuCfsPeriod;
-virCgroupGetCpuCfsQuota;
-virCgroupGetCpuShares;
virCgroupGetCpuacctPercpuUsage;
virCgroupGetCpuacctStat;
virCgroupGetCpuacctUsage;
+virCgroupGetCpuCfsPeriod;
+virCgroupGetCpuCfsQuota;
virCgroupGetCpusetCpus;
virCgroupGetCpusetMems;
+virCgroupGetCpuShares;
virCgroupGetFreezerState;
-virCgroupGetMemSwapUsage;
-virCgroupGetMemSwapHardLimit;
virCgroupGetMemoryHardLimit;
virCgroupGetMemorySoftLimit;
virCgroupGetMemoryUsage;
+virCgroupGetMemSwapHardLimit;
+virCgroupGetMemSwapUsage;
virCgroupKill;
virCgroupKillPainfully;
virCgroupKillRecursive;
@@ -115,14 +115,14 @@ virCgroupSetBlkioDeviceWeight;
virCgroupSetBlkioWeight;
virCgroupSetCpuCfsPeriod;
virCgroupSetCpuCfsQuota;
-virCgroupSetCpuShares;
virCgroupSetCpusetCpus;
virCgroupSetCpusetMems;
+virCgroupSetCpuShares;
virCgroupSetFreezerState;
-virCgroupSetMemSwapHardLimit;
virCgroupSetMemory;
virCgroupSetMemoryHardLimit;
virCgroupSetMemorySoftLimit;
+virCgroupSetMemSwapHardLimit;
# command.h
@@ -218,9 +218,9 @@ virGetConnect;
virGetDomain;
virGetDomainSnapshot;
virGetInterface;
-virGetNWFilter;
virGetNetwork;
virGetNodeDevice;
+virGetNWFilter;
virGetSecret;
virGetStoragePool;
virGetStorageVol;
@@ -249,9 +249,9 @@ dnsmasqAddHost;
dnsmasqCapsGet;
dnsmasqCapsGetBinaryPath;
dnsmasqCapsGetVersion;
+dnsmasqCapsNewFromBinary;
dnsmasqCapsNewFromBuffer;
dnsmasqCapsNewFromFile;
-dnsmasqCapsNewFromBinary;
dnsmasqCapsRefresh;
dnsmasqContextFree;
dnsmasqContextNew;
@@ -318,6 +318,7 @@ virDomainControllerTypeToString;
virDomainCpuPlacementModeTypeFromString;
virDomainCpuPlacementModeTypeToString;
virDomainDefAddImplicitControllers;
+virDomainDefAddSecurityLabelDef;
virDomainDefCheckABIStability;
virDomainDefClearDeviceAliases;
virDomainDefClearPCIAddresses;
@@ -327,8 +328,6 @@ virDomainDefFormat;
virDomainDefFormatInternal;
virDomainDefFree;
virDomainDefGetSecurityLabelDef;
-virDomainDiskDefGetSecurityLabelDef;
-virDomainDefAddSecurityLabelDef;
virDomainDefParseFile;
virDomainDefParseNode;
virDomainDefParseString;
@@ -349,6 +348,7 @@ virDomainDiskCopyOnReadTypeToString;
virDomainDiskDefAssignAddress;
virDomainDiskDefForeachPath;
virDomainDiskDefFree;
+virDomainDiskDefGetSecurityLabelDef;
virDomainDiskDeviceTypeToString;
virDomainDiskErrorPolicyTypeFromString;
virDomainDiskErrorPolicyTypeToString;
@@ -370,17 +370,17 @@ virDomainDiskTypeFromString;
virDomainDiskTypeToString;
virDomainEmulatorPinAdd;
virDomainEmulatorPinDel;
+virDomainFeatureStateTypeFromString;
+virDomainFeatureStateTypeToString;
+virDomainFindByID;
+virDomainFindByName;
+virDomainFindByUUID;
virDomainFSDefFree;
virDomainFSIndexByName;
virDomainFSTypeFromString;
virDomainFSTypeToString;
virDomainFSWrpolicyTypeFromString;
virDomainFSWrpolicyTypeToString;
-virDomainFeatureStateTypeFromString;
-virDomainFeatureStateTypeToString;
-virDomainFindByID;
-virDomainFindByName;
-virDomainFindByUUID;
virDomainGetRootFilesystem;
virDomainGraphicsAuthConnectedTypeFromString;
virDomainGraphicsAuthConnectedTypeToString;
@@ -536,14 +536,14 @@ virDomainVcpuPinDefFree;
virDomainVcpuPinDel;
virDomainVcpuPinFindByVcpu;
virDomainVcpuPinIsDuplicate;
-virDomainVideoDefFree;
virDomainVideoDefaultRAM;
virDomainVideoDefaultType;
+virDomainVideoDefFree;
virDomainVideoTypeFromString;
virDomainVideoTypeToString;
-virDomainVirtTypeToString;
virDomainVirtioEventIdxTypeFromString;
virDomainVirtioEventIdxTypeToString;
+virDomainVirtTypeToString;
virDomainWatchdogActionTypeFromString;
virDomainWatchdogActionTypeToString;
virDomainWatchdogModelTypeFromString;
@@ -553,8 +553,8 @@ virDomainWatchdogModelTypeToString;
# domain_event.h
virDomainEventBalloonChangeNewFromDom;
virDomainEventBalloonChangeNewFromObj;
-virDomainEventBlockJobNewFromObj;
virDomainEventBlockJobNewFromDom;
+virDomainEventBlockJobNewFromObj;
virDomainEventControlErrorNewFromDom;
virDomainEventControlErrorNewFromObj;
virDomainEventDiskChangeNewFromDom;
@@ -570,25 +570,25 @@ virDomainEventNew;
virDomainEventNewFromDef;
virDomainEventNewFromDom;
virDomainEventNewFromObj;
+virDomainEventPMSuspendDiskNewFromDom;
+virDomainEventPMSuspendDiskNewFromObj;
virDomainEventPMSuspendNewFromDom;
virDomainEventPMSuspendNewFromObj;
virDomainEventPMWakeupNewFromDom;
virDomainEventPMWakeupNewFromObj;
-virDomainEventRTCChangeNewFromDom;
-virDomainEventRTCChangeNewFromObj;
virDomainEventRebootNew;
virDomainEventRebootNewFromDom;
virDomainEventRebootNewFromObj;
+virDomainEventRTCChangeNewFromDom;
+virDomainEventRTCChangeNewFromObj;
virDomainEventStateDeregister;
virDomainEventStateDeregisterID;
virDomainEventStateEventID;
-virDomainEventStateRegister;
-virDomainEventStateRegisterID;
virDomainEventStateFree;
virDomainEventStateNew;
virDomainEventStateQueue;
-virDomainEventPMSuspendDiskNewFromDom;
-virDomainEventPMSuspendDiskNewFromObj;
+virDomainEventStateRegister;
+virDomainEventStateRegisterID;
virDomainEventTrayChangeNewFromDom;
virDomainEventTrayChangeNewFromObj;
virDomainEventWatchdogNewFromDom;
@@ -596,14 +596,14 @@ virDomainEventWatchdogNewFromObj;
# domain_lock.h
-virDomainLockProcessStart;
-virDomainLockProcessInquire;
-virDomainLockProcessPause;
-virDomainLockProcessResume;
virDomainLockDiskAttach;
virDomainLockDiskDetach;
virDomainLockLeaseAttach;
virDomainLockLeaseDetach;
+virDomainLockProcessInquire;
+virDomainLockProcessPause;
+virDomainLockProcessResume;
+virDomainLockProcessStart;
# domain_nwfilter.h
@@ -635,10 +635,10 @@ virEventPollUpdateTimeout;
# fdstream.h
-virFDStreamOpen;
virFDStreamConnectUNIX;
-virFDStreamOpenFile;
virFDStreamCreateFile;
+virFDStreamOpen;
+virFDStreamOpenFile;
# hash.h
@@ -757,24 +757,24 @@ virJSONValueToString;
# libvirt_internal.h
-virDomainMigrateFinish2;
+virDomainMigrateBegin3;
+virDomainMigrateConfirm3;
virDomainMigrateFinish;
+virDomainMigrateFinish2;
+virDomainMigrateFinish3;
virDomainMigratePerform;
-virDomainMigratePrepare2;
+virDomainMigratePerform3;
virDomainMigratePrepare;
-virDomainMigratePrepareTunnel;
-virDomainMigrateBegin3;
+virDomainMigratePrepare2;
virDomainMigratePrepare3;
+virDomainMigratePrepareTunnel;
virDomainMigratePrepareTunnel3;
-virDomainMigratePerform3;
-virDomainMigrateFinish3;
-virDomainMigrateConfirm3;
virDrvSupportsFeature;
virRegisterDeviceMonitor;
virRegisterDriver;
virRegisterInterfaceDriver;
-virRegisterNWFilterDriver;
virRegisterNetworkDriver;
+virRegisterNWFilterDriver;
virRegisterSecretDriver;
virRegisterStorageDriver;
@@ -785,11 +785,11 @@ virLockManagerAddResource;
virLockManagerFree;
virLockManagerInquire;
virLockManagerNew;
+virLockManagerPluginGetName;
virLockManagerPluginNew;
virLockManagerPluginRef;
virLockManagerPluginUnref;
virLockManagerPluginUsesState;
-virLockManagerPluginGetName;
virLockManagerRelease;
virLockManagerSetPluginDir;
@@ -847,8 +847,8 @@ virNetDevVPortTypeToString;
# network_conf.h
virNetworkAssignDef;
-virNetworkConfigFile;
virNetworkConfigChangeSetup;
+virNetworkConfigFile;
virNetworkDefCopy;
virNetworkDefFormat;
virNetworkDefFree;
@@ -885,9 +885,9 @@ virPortGroupFindByName;
# node_device_conf.h
+virNodeDevCapsDefFree;
virNodeDevCapTypeFromString;
virNodeDevCapTypeToString;
-virNodeDevCapsDefFree;
virNodeDeviceAssignDef;
virNodeDeviceDefFormat;
virNodeDeviceDefFree;
@@ -908,11 +908,11 @@ virNodeDeviceObjUnlock;
# nodeinfo.h
nodeCapsInitNUMA;
+nodeGetCellsFreeMemory;
nodeGetCPUBitmap;
nodeGetCPUCount;
nodeGetCPUMap;
nodeGetCPUStats;
-nodeGetCellsFreeMemory;
nodeGetFreeMemory;
nodeGetInfo;
nodeGetMemoryParameters;
@@ -949,8 +949,8 @@ virNWFilterRuleActionTypeToString;
virNWFilterRuleDirectionTypeToString;
virNWFilterRuleProtocolTypeToString;
virNWFilterTestUnassignDef;
-virNWFilterUnRegisterCallbackDriver;
virNWFilterUnlockFilterUpdates;
+virNWFilterUnRegisterCallbackDriver;
# nwfilter_ipaddrmap
@@ -1051,31 +1051,33 @@ virSecurityManagerFree;
virSecurityManagerGenLabel;
virSecurityManagerGetDOI;
virSecurityManagerGetModel;
+virSecurityManagerGetMountOptions;
virSecurityManagerGetNested;
virSecurityManagerGetProcessLabel;
virSecurityManagerNew;
-virSecurityManagerNewStack;
virSecurityManagerNewDAC;
+virSecurityManagerNewStack;
virSecurityManagerReleaseLabel;
virSecurityManagerReserveLabel;
-virSecurityManagerRestoreImageLabel;
virSecurityManagerRestoreAllLabel;
virSecurityManagerRestoreHostdevLabel;
+virSecurityManagerRestoreImageLabel;
virSecurityManagerRestoreSavedStateLabel;
virSecurityManagerSetAllLabel;
virSecurityManagerSetDaemonSocketLabel;
+virSecurityManagerSetHostdevLabel;
virSecurityManagerSetImageFDLabel;
virSecurityManagerSetImageLabel;
-virSecurityManagerSetHostdevLabel;
virSecurityManagerSetProcessLabel;
virSecurityManagerSetSavedStateLabel;
virSecurityManagerSetSocketLabel;
virSecurityManagerSetTapFDLabel;
virSecurityManagerStackAddNested;
virSecurityManagerVerify;
-virSecurityManagerGetMountOptions;
+
# sexpr.h
+sexpr2string;
sexpr_append;
sexpr_cons;
sexpr_float;
@@ -1089,7 +1091,6 @@ sexpr_node;
sexpr_node_copy;
sexpr_string;
sexpr_u64;
-sexpr2string;
string2sexpr;
@@ -1186,11 +1187,11 @@ virSysinfoRead;
# threadpool.h
virThreadPoolFree;
-virThreadPoolNew;
-virThreadPoolSendJob;
-virThreadPoolGetMinWorkers;
virThreadPoolGetMaxWorkers;
+virThreadPoolGetMinWorkers;
virThreadPoolGetPriorityWorkers;
+virThreadPoolNew;
+virThreadPoolSendJob;
# threads.h
@@ -1255,9 +1256,9 @@ virFileExists;
virFileFindMountPoint;
virFileHasSuffix;
virFileIsAbsPath;
+virFileIsDir;
virFileIsExecutable;
virFileIsLink;
-virFileIsDir;
virFileLinkPointsTo;
virFileLock;
virFileMakePath;
@@ -1280,12 +1281,12 @@ virFormatIntDecimal;
virGetGroupID;
virGetGroupName;
virGetHostname;
-virGetUserDirectory;
-virGetUserConfigDirectory;
virGetUserCacheDirectory;
-virGetUserRuntimeDirectory;
+virGetUserConfigDirectory;
+virGetUserDirectory;
virGetUserID;
virGetUserName;
+virGetUserRuntimeDirectory;
virHexToBin;
virIndexToDiskName;
virIsDevMapperDevice;
@@ -1301,7 +1302,9 @@ virSetUIDGID;
virSkipSpaces;
virSkipSpacesAndBackslash;
virSkipSpacesBackwards;
+virStrcpy;
virStrIsPrint;
+virStrncpy;
virStrToDouble;
virStrToLong_i;
virStrToLong_l;
@@ -1309,8 +1312,6 @@ virStrToLong_ll;
virStrToLong_ui;
virStrToLong_ul;
virStrToLong_ull;
-virStrcpy;
-virStrncpy;
virTrimSpaces;
virValidateWWN;
virVasprintf;
@@ -1358,18 +1359,18 @@ virDBusGetSystemBus;
# virfile.h
-virFileLoopDeviceAssociate;
virFileClose;
virFileDirectFdFlag;
-virFileWrapperFdCatchError;
-virFileWrapperFdClose;
-virFileWrapperFdFree;
-virFileWrapperFdNew;
virFileFclose;
virFileFdopen;
+virFileLoopDeviceAssociate;
virFileRewrite;
virFileTouch;
virFileUpdatePerm;
+virFileWrapperFdCatchError;
+virFileWrapperFdClose;
+virFileWrapperFdFree;
+virFileWrapperFdNew;
# virinitctl.h
@@ -1384,13 +1385,13 @@ virKeycodeValueTranslate;
# virkeyfile.h
-virKeyFileNew;
-virKeyFileLoadFile;
-virKeyFileLoadData;
virKeyFileFree;
-virKeyFileHasValue;
-virKeyFileHasGroup;
virKeyFileGetValueString;
+virKeyFileHasGroup;
+virKeyFileHasValue;
+virKeyFileLoadData;
+virKeyFileLoadFile;
+virKeyFileNew;
# virlockspace.h
@@ -1444,8 +1445,8 @@ virNetClientRegisterAsyncIO;
virNetClientRegisterKeepAlive;
virNetClientRemoteAddrString;
virNetClientRemoveStream;
-virNetClientSendNoReply;
virNetClientSendNonBlock;
+virNetClientSendNoReply;
virNetClientSendWithReply;
virNetClientSendWithReplyStream;
virNetClientSetCloseCallback;
@@ -1478,15 +1479,15 @@ virNetClientStreamSetError;
# virnetdev.h
virNetDevClearIPv4Address;
virNetDevExists;
-virNetDevGetIPv4Address;
virNetDevGetIndex;
+virNetDevGetIPv4Address;
virNetDevGetMAC;
virNetDevGetMTU;
virNetDevGetPhysicalFunction;
-virNetDevGetVLanID;
virNetDevGetVirtualFunctionIndex;
virNetDevGetVirtualFunctionInfo;
virNetDevGetVirtualFunctions;
+virNetDevGetVLanID;
virNetDevIsOnline;
virNetDevIsVirtualFunction;
virNetDevLinkDump;
@@ -1528,8 +1529,8 @@ virNetDevBridgeSetSTPDelay;
# virnetdevmacvlan.h
virNetDevMacVLanCreate;
-virNetDevMacVLanDelete;
virNetDevMacVLanCreateWithVPortProfile;
+virNetDevMacVLanDelete;
virNetDevMacVLanDeleteWithVPortProfile;
virNetDevMacVLanRestartWithVPortProfile;
virNetDevMacVLanVPortProfileRegisterCallback;
@@ -1576,9 +1577,9 @@ virNetlinkEventAddClient;
virNetlinkEventRemoveClient;
virNetlinkEventServiceIsRunning;
virNetlinkEventServiceLocalPid;
+virNetlinkEventServiceStart;
virNetlinkEventServiceStop;
virNetlinkEventServiceStopAll;
-virNetlinkEventServiceStart;
virNetlinkShutdown;
virNetlinkStartup;
@@ -1586,14 +1587,14 @@ virNetlinkStartup;
# virnetmessage.h
virNetMessageClear;
virNetMessageDecodeHeader;
-virNetMessageDecodeNumFDs;
virNetMessageDecodeLength;
+virNetMessageDecodeNumFDs;
virNetMessageDecodePayload;
virNetMessageDupFD;
virNetMessageEncodeHeader;
+virNetMessageEncodeNumFDs;
virNetMessageEncodePayload;
virNetMessageEncodePayloadRaw;
-virNetMessageEncodeNumFDs;
virNetMessageFree;
virNetMessageNew;
virNetMessageQueuePush;
@@ -1766,6 +1767,8 @@ virObjectUnref;
virPidFileAcquire;
virPidFileAcquirePath;
virPidFileBuildPath;
+virPidFileDelete;
+virPidFileDeletePath;
virPidFileRead;
virPidFileReadIfAlive;
virPidFileReadPath;
@@ -1774,8 +1777,6 @@ virPidFileRelease;
virPidFileReleasePath;
virPidFileWrite;
virPidFileWritePath;
-virPidFileDelete;
-virPidFileDeletePath;
# virprocess.h
@@ -1827,9 +1828,9 @@ virStrerror;
# virstring.h
-virStringSplit;
-virStringJoin;
virStringFreeList;
+virStringJoin;
+virStringSplit;
# virtime.h
--
1.7.11.7
12 years
[libvirt] [PATCH RESEND] tools: Only install guests init script if --with-init=script=redhat
by Cole Robinson
Most of this deals with moving the libvirt-guests.sh script which
does all the work to /usr/libexec, so it can be shared by both
systemd and traditional init. Previously systemd depended on
the script being in /etc/init.d
Required to fix https://bugzilla.redhat.com/show_bug.cgi?id=789747
---
Only change to the big script is dropping the LSB header
.gitignore | 1 +
libvirt.spec.in | 6 +-
po/POTFILES.in | 2 +-
tools/Makefile.am | 18 +-
tools/libvirt-guests.init.in | 27 ++
tools/libvirt-guests.init.sh | 597 ----------------------------------------
tools/libvirt-guests.service.in | 4 +-
tools/libvirt-guests.sh.in | 573 ++++++++++++++++++++++++++++++++++++++
8 files changed, 620 insertions(+), 608 deletions(-)
create mode 100644 tools/libvirt-guests.init.in
delete mode 100644 tools/libvirt-guests.init.sh
create mode 100644 tools/libvirt-guests.sh.in
diff --git a/.gitignore b/.gitignore
index 0dadd21..ca7d07a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -179,6 +179,7 @@
/tools/*.[18]
/tools/libvirt-guests.init
/tools/libvirt-guests.service
+/tools/libvirt-guests.sh
/tools/virsh
/tools/virsh-*-edit.c
/tools/virt-*-validate
diff --git a/libvirt.spec.in b/libvirt.spec.in
index d6e1fbe..d463c27 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1409,8 +1409,6 @@ rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/libvirtd.uml
mv $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-%{version} \
$RPM_BUILD_ROOT%{_datadir}/doc/libvirt-docs-%{version}
-sed -i -e "s|$RPM_BUILD_ROOT||g" $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/libvirt-guests
-
%if %{with_dtrace}
%ifarch %{power64} s390x x86_64 ia64 alpha sparc64
mv $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_probes.stp \
@@ -1657,10 +1655,13 @@ fi
%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/nwfilter/
+%attr(0755, root, root) %{_libexecdir}/libvirt-guests.sh
%if %{with_systemd}
%{_unitdir}/libvirtd.service
+%{_unitdir}/libvirt-guests.service
%else
%{_sysconfdir}/rc.d/init.d/libvirtd
+%{_sysconfdir}/rc.d/init.d/libvirt-guests
%endif
%doc daemon/libvirtd.upstart
%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
@@ -1925,7 +1926,6 @@ rm -f $RPM_BUILD_ROOT%{_sysconfdir}/sysctl.d/libvirtd
%{_datadir}/libvirt/cpu_map.xml
-%{_sysconfdir}/rc.d/init.d/libvirt-guests
%if %{with_systemd}
%{_unitdir}/libvirt-guests.service
%endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 586aa2b..6d78f48 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -194,7 +194,7 @@ src/xenapi/xenapi_utils.c
src/xenxs/xen_sxpr.c
src/xenxs/xen_xm.c
tools/console.c
-tools/libvirt-guests.init.sh
+tools/libvirt-guests.sh.in
tools/virsh.c
tools/virsh-domain-monitor.c
tools/virsh-domain.c
diff --git a/tools/Makefile.am b/tools/Makefile.am
index d646bab..605bf3b 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -41,6 +41,7 @@ DISTCLEANFILES =
bin_SCRIPTS = virt-xml-validate virt-pki-validate
bin_PROGRAMS = virsh virt-host-validate
+libexec_SCRIPTS = libvirt-guests.sh
if HAVE_SANLOCK
sbin_SCRIPTS = virt-sanlock-cleanup
@@ -187,7 +188,7 @@ uninstall-sysconfig:
rm -f $(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests
rmdir $(DESTDIR)$(sysconfdir)/sysconfig ||:
-EXTRA_DIST += libvirt-guests.init.sh
+EXTRA_DIST += libvirt-guests.sh.in libvirt-guests.init.in
install-initscript: libvirt-guests.init
$(MKDIR_P) $(DESTDIR)$(sysconfdir)/rc.d/init.d
@@ -208,7 +209,7 @@ install-init:
uninstall-init:
endif # LIBVIRT_INIT_SCRIPT_RED_HAT
-libvirt-guests.init: libvirt-guests.init.sh $(top_builddir)/config.status
+libvirt-guests.sh: libvirt-guests.sh.in $(top_builddir)/config.status
$(AM_V_GEN)sed \
-e 's!\@PACKAGE\@!$(PACKAGE)!g' \
-e 's!\@bindir\@!$(bindir)!g' \
@@ -219,20 +220,26 @@ libvirt-guests.init: libvirt-guests.init.sh $(top_builddir)/config.status
< $< > $@-t && \
chmod a+x $@-t && \
mv $@-t $@
+BUILT_SOURCES += libvirt-guests.sh
+libvirt-guests.init: libvirt-guests.init.in libvirt-guests.sh
+ $(AM_V_GEN)sed \
+ -e 's!\@libexecdir\@!$(libexecdir)!g' \
+ < $< > $@-t && \
+ chmod a+x $@-t && \
+ mv $@-t $@
EXTRA_DIST += libvirt-guests.service.in
-
SYSTEMD_UNIT_DIR = /lib/systemd/system
if LIBVIRT_INIT_SCRIPT_SYSTEMD
-install-systemd: libvirt-guests.service install-initscript install-sysconfig
+install-systemd: libvirt-guests.service install-sysconfig libvirt-guests.sh
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA) libvirt-guests.service \
$(DESTDIR)$(SYSTEMD_UNIT_DIR)/libvirt-guests.service
-uninstall-systemd: uninstall-initscript uninstall-sysconfig
+uninstall-systemd: uninstall-sysconfig
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/libvirt-guests.service
rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) ||:
@@ -251,6 +258,7 @@ libvirt-guests.service: libvirt-guests.service.in $(top_builddir)/config.status
-e 's!\@localstatedir\@!$(localstatedir)!g' \
-e 's!\@sbindir\@!$(sbindir)!g' \
-e 's!\@sysconfdir\@!$(sysconfdir)!g' \
+ -e 's!\@libexecdir\@!$(libexecdir)!g' \
< $< > $@-t && \
chmod a+x $@-t && \
mv $@-t $@
diff --git a/tools/libvirt-guests.init.in b/tools/libvirt-guests.init.in
new file mode 100644
index 0000000..5f9a60e
--- /dev/null
+++ b/tools/libvirt-guests.init.in
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# the following is the LSB init header
+#
+### BEGIN INIT INFO
+# Provides: libvirt-guests
+# Required-Start: libvirtd
+# Required-Stop: libvirtd
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: suspend/resume libvirt guests on shutdown/boot
+# Description: This is a script for suspending active libvirt guests
+# on shutdown and resuming them on next boot
+# See http://libvirt.org
+### END INIT INFO
+
+# the following is chkconfig init header
+#
+# libvirt-guests: suspend/resume libvirt guests on shutdown/boot
+#
+# chkconfig: 345 99 01
+# description: This is a script for suspending active libvirt guests \
+# on shutdown and resuming them on next boot \
+# See http://libvirt.org
+#
+
+exec @libexecdir(a)/libvirt-guests.sh "$@"
diff --git a/tools/libvirt-guests.init.sh b/tools/libvirt-guests.init.sh
deleted file mode 100644
index 99ef331..0000000
--- a/tools/libvirt-guests.init.sh
+++ /dev/null
@@ -1,597 +0,0 @@
-#!/bin/sh
-
-# the following is the LSB init header
-#
-### BEGIN INIT INFO
-# Provides: libvirt-guests
-# Required-Start: libvirtd
-# Required-Stop: libvirtd
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: suspend/resume libvirt guests on shutdown/boot
-# Description: This is a script for suspending active libvirt guests
-# on shutdown and resuming them on next boot
-# See http://libvirt.org
-### END INIT INFO
-
-# the following is chkconfig init header
-#
-# libvirt-guests: suspend/resume libvirt guests on shutdown/boot
-#
-# chkconfig: 345 99 01
-# description: This is a script for suspending active libvirt guests \
-# on shutdown and resuming them on next boot \
-# See http://libvirt.org
-#
-
-sysconfdir="@sysconfdir@"
-localstatedir="@localstatedir@"
-libvirtd="@sbindir@"/libvirtd
-
-# Source function library.
-test ! -r "$sysconfdir"/rc.d/init.d/functions ||
- . "$sysconfdir"/rc.d/init.d/functions
-
-# Source gettext library.
-# Make sure this file is recognized as having translations: _("dummy")
-. "@bindir@"/gettext.sh
-
-export TEXTDOMAIN="@PACKAGE@" TEXTDOMAINDIR="@localedir@"
-
-URIS=default
-ON_BOOT=start
-ON_SHUTDOWN=suspend
-SHUTDOWN_TIMEOUT=300
-PARALLEL_SHUTDOWN=0
-START_DELAY=0
-BYPASS_CACHE=0
-
-test -f "$sysconfdir"/sysconfig/libvirt-guests &&
- . "$sysconfdir"/sysconfig/libvirt-guests
-
-LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests
-VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests
-
-RETVAL=0
-
-# retval COMMAND ARGUMENTS...
-# run command with arguments and convert non-zero return value to 1 and set
-# the global return variable
-retval() {
- "$@"
- if [ $? -ne 0 ]; then
- RETVAL=1
- return 1
- else
- return 0
- fi
-}
-
-# run_virsh URI ARGUMENTS...
-# start virsh and let it execute ARGUMENTS on URI
-# If URI is "default" virsh is called without the "-c" argument
-# (using libvirt's default connection)
-run_virsh() {
- uri=$1
- shift
-
- if [ "x$uri" = xdefault ]; then
- virsh "$@" </dev/null
- else
- virsh -c "$uri" "$@" </dev/null
- fi
-}
-
-# run_virsh_c URI ARGUMENTS
-# Same as "run_virsh" but the "C" locale is used instead of
-# the system's locale.
-run_virsh_c() {
- ( export LC_ALL=C; run_virsh "$@" )
-}
-
-# test_connect URI
-# check if URI is reachable
-test_connect()
-{
- uri=$1
-
- run_virsh "$uri" connect 2>/dev/null
- if [ $? -ne 0 ]; then
- eval_gettext "Can't connect to \$uri. Skipping."
- echo
- return 1
- fi
-}
-
-# list_guests URI PERSISTENT
-# List running guests on URI.
-# PERSISTENT argument options:
-# --persistent: list only persistent guests
-# --transient: list only transient guests
-# [none]: list both persistent and transient guests
-list_guests() {
- uri=$1
- persistent=$2
-
- list=$(run_virsh_c "$uri" list --uuid $persistent)
- if [ $? -ne 0 ]; then
- RETVAL=1
- return 1
- fi
-
- echo $list
-}
-
-# guest_name URI UUID
-# return name of guest UUID on URI
-guest_name() {
- uri=$1
- uuid=$2
-
- run_virsh "$uri" domname "$uuid" 2>/dev/null
-}
-
-# guest_is_on URI UUID
-# check if guest UUID on URI is running
-# Result is returned by variable "guest_running"
-guest_is_on() {
- uri=$1
- uuid=$2
-
- guest_running=false
- id=$(run_virsh "$uri" domid "$uuid")
- if [ $? -ne 0 ]; then
- RETVAL=1
- return 1
- fi
-
- [ -n "$id" ] && [ "x$id" != x- ] && guest_running=true
- return 0
-}
-
-# started
-# Create the startup lock file
-started() {
- touch "$VAR_SUBSYS_LIBVIRT_GUESTS"
-}
-
-# start
-# Start or resume the guests
-start() {
- [ -f "$LISTFILE" ] || { started; return 0; }
-
- if [ "x$ON_BOOT" != xstart ]; then
- gettext "libvirt-guests is configured not to start any guests on boot"
- echo
- rm -f "$LISTFILE"
- started
- return 0
- fi
-
- isfirst=true
- bypass=
- test "x$BYPASS_CACHE" = x0 || bypass=--bypass-cache
- while read uri list; do
- configured=false
- set -f
- for confuri in $URIS; do
- set +f
- if [ "x$confuri" = "x$uri" ]; then
- configured=true
- break
- fi
- done
- set +f
- if ! "$configured"; then
- eval_gettext "Ignoring guests on \$uri URI"; echo
- continue
- fi
-
- test_connect "$uri" || continue
-
- eval_gettext "Resuming guests on \$uri URI..."; echo
- for guest in $list; do
- name=$(guest_name "$uri" "$guest")
- eval_gettext "Resuming guest \$name: "
- if guest_is_on "$uri" "$guest"; then
- if "$guest_running"; then
- gettext "already active"; echo
- else
- if "$isfirst"; then
- isfirst=false
- else
- sleep $START_DELAY
- fi
- retval run_virsh "$uri" start $bypass "$name" \
- >/dev/null && \
- gettext "done"; echo
- fi
- fi
- done
- done <"$LISTFILE"
-
- rm -f "$LISTFILE"
- started
-}
-
-# suspend_guest URI GUEST
-# Do a managed save on a GUEST on URI. This function returns after the guest
-# was saved.
-suspend_guest()
-{
- uri=$1
- guest=$2
-
- name=$(guest_name "$uri" "$guest")
- label=$(eval_gettext "Suspending \$name: ")
- bypass=
- slept=0
- test "x$BYPASS_CACHE" = x0 || bypass=--bypass-cache
- printf '%s...\n' "$label"
- run_virsh "$uri" managedsave $bypass "$guest" >/dev/null &
- virsh_pid=$!
- while true; do
- sleep 1
- kill -0 "$virsh_pid" >/dev/null 2>&1 || break
-
- slept=$(($slept + 1))
- if [ $(($slept % 5)) -eq 0 ]; then
- progress=$(run_virsh_c "$uri" domjobinfo "$guest" 2>/dev/null | \
- awk '/^Data processed:/{print $3, $4}')
- if [ -n "$progress" ]; then
- printf '%s%s\n' "$label" "$progress"
- else
- printf '%s%s\n' "$label" "..."
- fi
- fi
- done
- retval wait "$virsh_pid" && printf '%s%s\n' "$label" "$(gettext "done")"
-}
-
-# shutdown_guest URI GUEST
-# Start a ACPI shutdown of GUEST on URI. This function return after the quest
-# was successfully shutdown or the timeout defined by $SHUTDOWN_TIMEOUT expires.
-shutdown_guest()
-{
- uri=$1
- guest=$2
-
- name=$(guest_name "$uri" "$guest")
- eval_gettext "Starting shutdown on guest: \$name"
- echo
- retval run_virsh "$uri" shutdown "$guest" >/dev/null || return
- timeout=$SHUTDOWN_TIMEOUT
- check_timeout=false
- if [ $timeout -gt 0 ]; then
- check_timeout=true
- format=$(eval_gettext "Waiting for guest %s to shut down, %d seconds left\n")
- else
- slept=0
- format=$(eval_gettext "Waiting for guest %s to shut down\n")
- fi
- while ! $check_timeout || [ "$timeout" -gt 0 ]; do
- sleep 1
- guest_is_on "$uri" "$guest" || return
- "$guest_running" || break
-
- if $check_timeout; then
- if [ $(($timeout % 5)) -eq 0 ]; then
- printf "$format" "$name" "$timeout"
- fi
- timeout=$(($timeout - 1))
- else
- slept=$(($slept + 1))
- if [ $(($slept % 5)) -eq 0 ]; then
- printf "$format" "$name"
- fi
- fi
- done
-
- if guest_is_on "$uri" "$guest"; then
- if "$guest_running"; then
- eval_gettext "Shutdown of guest \$name failed to complete in time."
- else
- eval_gettext "Shutdown of guest \$name complete."
- fi
- fi
-}
-
-# shutdown_guest_async URI GUEST
-# Start a ACPI shutdown of GUEST on URI. This function returns after the command
-# was issued to libvirt to allow parallel shutdown.
-shutdown_guest_async()
-{
- uri=$1
- guest=$2
-
- name=$(guest_name "$uri" "$guest")
- eval_gettext "Starting shutdown on guest: \$name"
- echo
- retval run_virsh "$uri" shutdown "$guest" > /dev/null
-}
-
-# guest_count GUEST_LIST
-# Returns number of guests in GUEST_LIST
-guest_count()
-{
- set -- $1
- echo $#
-}
-
-# check_guests_shutdown URI GUESTS
-# check if shutdown is complete on guests in "GUESTS" and returns only
-# guests that are still shutting down
-check_guests_shutdown()
-{
- uri=$1
- guests=$2
-
- guests_up=
- for guest in $guests; do
- if ! guest_is_on "$uri" "$guest" >/dev/null 2>&1; then
- eval_gettext "Failed to determine state of guest: \$guest. Not tracking it anymore."
- echo
- continue
- fi
- if "$guest_running"; then
- guests_up="$guests_up $guest"
- fi
- done
- echo "$guests_up"
-}
-
-# print_guests_shutdown URI BEFORE AFTER
-# Checks for differences in the lists BEFORE and AFTER and prints
-# a shutdown complete notice for guests that have finished
-print_guests_shutdown()
-{
- uri=$1
- before=$2
- after=$3
-
- for guest in $before; do
- case " $after " in
- *" $guest "*) continue;;
- esac
-
- name=$(guest_name "$uri" "$guest")
- eval_gettext "Shutdown of guest \$name complete."
- echo
- done
-}
-
-# shutdown_guests_parallel URI GUESTS
-# Shutdown guests GUESTS on machine URI in parallel
-shutdown_guests_parallel()
-{
- uri=$1
- guests=$2
-
- on_shutdown=
- check_timeout=false
- timeout=$SHUTDOWN_TIMEOUT
- if [ $timeout -gt 0 ]; then
- check_timeout=true
- format=$(eval_gettext "Waiting for %d guests to shut down, %d seconds left\n")
- else
- slept=0
- format=$(eval_gettext "Waiting for %d guests to shut down\n")
- fi
- while [ -n "$on_shutdown" ] || [ -n "$guests" ]; do
- while [ -n "$guests" ] &&
- [ $(guest_count "$on_shutdown") -lt "$PARALLEL_SHUTDOWN" ]; do
- set -- $guests
- guest=$1
- shift
- guests=$*
- shutdown_guest_async "$uri" "$guest"
- on_shutdown="$on_shutdown $guest"
- done
- sleep 1
-
- set -- $guests
- guestcount=$#
- set -- $on_shutdown
- shutdowncount=$#
-
- if $check_timeout; then
- if [ $(($timeout % 5)) -eq 0 ]; then
- printf "$format" $(($guestcount + $shutdowncount)) "$timeout"
- fi
- timeout=$(($timeout - 1))
- if [ $timeout -le 0 ]; then
- eval_gettext "Timeout expired while shutting down domains"; echo
- RETVAL=1
- return
- fi
- else
- slept=$(($slept + 1))
- if [ $(($slept % 5)) -eq 0 ]; then
- printf "$format" $(($guestcount + $shutdowncount))
- fi
- fi
-
- on_shutdown_prev=$on_shutdown
- on_shutdown=$(check_guests_shutdown "$uri" "$on_shutdown")
- print_guests_shutdown "$uri" "$on_shutdown_prev" "$on_shutdown"
- done
-}
-
-# stop
-# Shutdown or save guests on the configured uris
-stop() {
- # last stop was not followed by start
- [ -f "$LISTFILE" ] && return 0
-
- suspending=true
- if [ "x$ON_SHUTDOWN" = xshutdown ]; then
- suspending=false
- if [ $SHUTDOWN_TIMEOUT -lt 0 ]; then
- gettext "SHUTDOWN_TIMEOUT must be equal or greater than 0"
- echo
- RETVAL=6
- return
- fi
- fi
-
- : >"$LISTFILE"
- set -f
- for uri in $URIS; do
- set +f
-
- test_connect "$uri" || continue
-
- eval_gettext "Running guests on \$uri URI: "
-
- list=$(list_guests "$uri")
- if [ $? -eq 0 ]; then
- empty=true
- for uuid in $list; do
- "$empty" || printf ", "
- printf %s "$(guest_name "$uri" "$uuid")"
- empty=false
- done
-
- if "$empty"; then
- gettext "no running guests."
- fi
- echo
- fi
-
- if "$suspending"; then
- transient=$(list_guests "$uri" "--transient")
- if [ $? -eq 0 ]; then
- empty=true
- for uuid in $transient; do
- if "$empty"; then
- eval_gettext "Not suspending transient guests on URI: \$uri: "
- empty=false
- else
- printf ", "
- fi
- printf %s "$(guest_name "$uri" "$uuid")"
- done
- echo
- # reload domain list to contain only persistent guests
- list=$(list_guests "$uri" "--persistent")
- if [ $? -ne 0 ]; then
- eval_gettext "Failed to list persistent guests on \$uri"
- echo
- RETVAL=1
- set +f
- return
- fi
- else
- gettext "Failed to list transient guests"
- echo
- RETVAL=1
- set +f
- return
- fi
- fi
-
- if [ -n "$list" ]; then
- echo "$uri" "$list" >>"$LISTFILE"
- fi
- done
- set +f
-
- if [ -s "$LISTFILE" ]; then
- while read uri list; do
- if "$suspending"; then
- eval_gettext "Suspending guests on \$uri URI..."; echo
- else
- eval_gettext "Shutting down guests on \$uri URI..."; echo
- fi
-
- if [ "$PARALLEL_SHUTDOWN" -gt 1 ] &&
- ! "$suspending"; then
- shutdown_guests_parallel "$uri" "$list"
- else
- for guest in $list; do
- if "$suspending"; then
- suspend_guest "$uri" "$guest"
- else
- shutdown_guest "$uri" "$guest"
- fi
- done
- fi
- done <"$LISTFILE"
- else
- rm -f "$LISTFILE"
- fi
-
- rm -f "$VAR_SUBSYS_LIBVIRT_GUESTS"
-}
-
-# gueststatus
-# List status of guests
-gueststatus() {
- set -f
- for uri in $URIS; do
- set +f
- echo "* $uri URI:"
- retval run_virsh "$uri" list || echo
- done
- set +f
-}
-
-# rh_status
-# Display current status: whether saved state exists, and whether start
-# has been executed. We cannot use status() from the functions library,
-# since there is no external daemon process matching this init script.
-rh_status() {
- if [ -f "$LISTFILE" ]; then
- gettext "stopped, with saved guests"; echo
- RETVAL=3
- else
- if [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ]; then
- gettext "started"; echo
- else
- gettext "stopped, with no saved guests"; echo
- fi
- RETVAL=0
- fi
-}
-
-# usage [val]
-# Display usage string, then exit with VAL (defaults to 2).
-usage() {
- program_name=$0
- eval_gettext "Usage: \$program_name {start|stop|status|restart|"\
-"condrestart|try-restart|reload|force-reload|gueststatus|shutdown}"; echo
- exit ${1-2}
-}
-
-# See how we were called.
-if test $# != 1; then
- usage
-fi
-case "$1" in
- --help)
- usage 0
- ;;
- start|stop|gueststatus)
- "$1"
- ;;
- restart)
- stop && start
- ;;
- condrestart|try-restart)
- [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ] && stop && start
- ;;
- reload|force-reload)
- # Nothing to do; we reread configuration on each invocation
- ;;
- status)
- rh_status
- ;;
- shutdown)
- ON_SHUTDOWN=shutdown
- stop
- ;;
- *)
- usage
- ;;
-esac
-exit $RETVAL
diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in
index 0f0c41c..d41bf2b 100644
--- a/tools/libvirt-guests.service.in
+++ b/tools/libvirt-guests.service.in
@@ -6,8 +6,8 @@ After=syslog.target network.target
EnvironmentFile=-/etc/sysconfig/libvirt-guests
# Hack just call traditional service until we factor
# out the code
-ExecStart=/etc/init.d/libvirt-guests start
-ExecStop=/etc/init.d/libvirt-guests stop
+ExecStart=@libexecdir(a)/libvirt-guests.sh start
+ExecStop=@libexecdir(a)/libvirt-guests.sh stop
Type=oneshot
RemainAfterExit=yes
StandardOutput=journal+console
diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
new file mode 100644
index 0000000..1c9c46b
--- /dev/null
+++ b/tools/libvirt-guests.sh.in
@@ -0,0 +1,573 @@
+#!/bin/sh
+
+sysconfdir="@sysconfdir@"
+localstatedir="@localstatedir@"
+libvirtd="@sbindir@"/libvirtd
+
+# Source function library.
+test ! -r "$sysconfdir"/rc.d/init.d/functions ||
+ . "$sysconfdir"/rc.d/init.d/functions
+
+# Source gettext library.
+# Make sure this file is recognized as having translations: _("dummy")
+. "@bindir@"/gettext.sh
+
+export TEXTDOMAIN="@PACKAGE@" TEXTDOMAINDIR="@localedir@"
+
+URIS=default
+ON_BOOT=start
+ON_SHUTDOWN=suspend
+SHUTDOWN_TIMEOUT=300
+PARALLEL_SHUTDOWN=0
+START_DELAY=0
+BYPASS_CACHE=0
+
+test -f "$sysconfdir"/sysconfig/libvirt-guests &&
+ . "$sysconfdir"/sysconfig/libvirt-guests
+
+LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests
+VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests
+
+RETVAL=0
+
+# retval COMMAND ARGUMENTS...
+# run command with arguments and convert non-zero return value to 1 and set
+# the global return variable
+retval() {
+ "$@"
+ if [ $? -ne 0 ]; then
+ RETVAL=1
+ return 1
+ else
+ return 0
+ fi
+}
+
+# run_virsh URI ARGUMENTS...
+# start virsh and let it execute ARGUMENTS on URI
+# If URI is "default" virsh is called without the "-c" argument
+# (using libvirt's default connection)
+run_virsh() {
+ uri=$1
+ shift
+
+ if [ "x$uri" = xdefault ]; then
+ virsh "$@" </dev/null
+ else
+ virsh -c "$uri" "$@" </dev/null
+ fi
+}
+
+# run_virsh_c URI ARGUMENTS
+# Same as "run_virsh" but the "C" locale is used instead of
+# the system's locale.
+run_virsh_c() {
+ ( export LC_ALL=C; run_virsh "$@" )
+}
+
+# test_connect URI
+# check if URI is reachable
+test_connect()
+{
+ uri=$1
+
+ run_virsh "$uri" connect 2>/dev/null
+ if [ $? -ne 0 ]; then
+ eval_gettext "Can't connect to \$uri. Skipping."
+ echo
+ return 1
+ fi
+}
+
+# list_guests URI PERSISTENT
+# List running guests on URI.
+# PERSISTENT argument options:
+# --persistent: list only persistent guests
+# --transient: list only transient guests
+# [none]: list both persistent and transient guests
+list_guests() {
+ uri=$1
+ persistent=$2
+
+ list=$(run_virsh_c "$uri" list --uuid $persistent)
+ if [ $? -ne 0 ]; then
+ RETVAL=1
+ return 1
+ fi
+
+ echo $list
+}
+
+# guest_name URI UUID
+# return name of guest UUID on URI
+guest_name() {
+ uri=$1
+ uuid=$2
+
+ run_virsh "$uri" domname "$uuid" 2>/dev/null
+}
+
+# guest_is_on URI UUID
+# check if guest UUID on URI is running
+# Result is returned by variable "guest_running"
+guest_is_on() {
+ uri=$1
+ uuid=$2
+
+ guest_running=false
+ id=$(run_virsh "$uri" domid "$uuid")
+ if [ $? -ne 0 ]; then
+ RETVAL=1
+ return 1
+ fi
+
+ [ -n "$id" ] && [ "x$id" != x- ] && guest_running=true
+ return 0
+}
+
+# started
+# Create the startup lock file
+started() {
+ touch "$VAR_SUBSYS_LIBVIRT_GUESTS"
+}
+
+# start
+# Start or resume the guests
+start() {
+ [ -f "$LISTFILE" ] || { started; return 0; }
+
+ if [ "x$ON_BOOT" != xstart ]; then
+ gettext "libvirt-guests is configured not to start any guests on boot"
+ echo
+ rm -f "$LISTFILE"
+ started
+ return 0
+ fi
+
+ isfirst=true
+ bypass=
+ test "x$BYPASS_CACHE" = x0 || bypass=--bypass-cache
+ while read uri list; do
+ configured=false
+ set -f
+ for confuri in $URIS; do
+ set +f
+ if [ "x$confuri" = "x$uri" ]; then
+ configured=true
+ break
+ fi
+ done
+ set +f
+ if ! "$configured"; then
+ eval_gettext "Ignoring guests on \$uri URI"; echo
+ continue
+ fi
+
+ test_connect "$uri" || continue
+
+ eval_gettext "Resuming guests on \$uri URI..."; echo
+ for guest in $list; do
+ name=$(guest_name "$uri" "$guest")
+ eval_gettext "Resuming guest \$name: "
+ if guest_is_on "$uri" "$guest"; then
+ if "$guest_running"; then
+ gettext "already active"; echo
+ else
+ if "$isfirst"; then
+ isfirst=false
+ else
+ sleep $START_DELAY
+ fi
+ retval run_virsh "$uri" start $bypass "$name" \
+ >/dev/null && \
+ gettext "done"; echo
+ fi
+ fi
+ done
+ done <"$LISTFILE"
+
+ rm -f "$LISTFILE"
+ started
+}
+
+# suspend_guest URI GUEST
+# Do a managed save on a GUEST on URI. This function returns after the guest
+# was saved.
+suspend_guest()
+{
+ uri=$1
+ guest=$2
+
+ name=$(guest_name "$uri" "$guest")
+ label=$(eval_gettext "Suspending \$name: ")
+ bypass=
+ slept=0
+ test "x$BYPASS_CACHE" = x0 || bypass=--bypass-cache
+ printf '%s...\n' "$label"
+ run_virsh "$uri" managedsave $bypass "$guest" >/dev/null &
+ virsh_pid=$!
+ while true; do
+ sleep 1
+ kill -0 "$virsh_pid" >/dev/null 2>&1 || break
+
+ slept=$(($slept + 1))
+ if [ $(($slept % 5)) -eq 0 ]; then
+ progress=$(run_virsh_c "$uri" domjobinfo "$guest" 2>/dev/null | \
+ awk '/^Data processed:/{print $3, $4}')
+ if [ -n "$progress" ]; then
+ printf '%s%s\n' "$label" "$progress"
+ else
+ printf '%s%s\n' "$label" "..."
+ fi
+ fi
+ done
+ retval wait "$virsh_pid" && printf '%s%s\n' "$label" "$(gettext "done")"
+}
+
+# shutdown_guest URI GUEST
+# Start a ACPI shutdown of GUEST on URI. This function return after the quest
+# was successfully shutdown or the timeout defined by $SHUTDOWN_TIMEOUT expires.
+shutdown_guest()
+{
+ uri=$1
+ guest=$2
+
+ name=$(guest_name "$uri" "$guest")
+ eval_gettext "Starting shutdown on guest: \$name"
+ echo
+ retval run_virsh "$uri" shutdown "$guest" >/dev/null || return
+ timeout=$SHUTDOWN_TIMEOUT
+ check_timeout=false
+ if [ $timeout -gt 0 ]; then
+ check_timeout=true
+ format=$(eval_gettext "Waiting for guest %s to shut down, %d seconds left\n")
+ else
+ slept=0
+ format=$(eval_gettext "Waiting for guest %s to shut down\n")
+ fi
+ while ! $check_timeout || [ "$timeout" -gt 0 ]; do
+ sleep 1
+ guest_is_on "$uri" "$guest" || return
+ "$guest_running" || break
+
+ if $check_timeout; then
+ if [ $(($timeout % 5)) -eq 0 ]; then
+ printf "$format" "$name" "$timeout"
+ fi
+ timeout=$(($timeout - 1))
+ else
+ slept=$(($slept + 1))
+ if [ $(($slept % 5)) -eq 0 ]; then
+ printf "$format" "$name"
+ fi
+ fi
+ done
+
+ if guest_is_on "$uri" "$guest"; then
+ if "$guest_running"; then
+ eval_gettext "Shutdown of guest \$name failed to complete in time."
+ else
+ eval_gettext "Shutdown of guest \$name complete."
+ fi
+ fi
+}
+
+# shutdown_guest_async URI GUEST
+# Start a ACPI shutdown of GUEST on URI. This function returns after the command
+# was issued to libvirt to allow parallel shutdown.
+shutdown_guest_async()
+{
+ uri=$1
+ guest=$2
+
+ name=$(guest_name "$uri" "$guest")
+ eval_gettext "Starting shutdown on guest: \$name"
+ echo
+ retval run_virsh "$uri" shutdown "$guest" > /dev/null
+}
+
+# guest_count GUEST_LIST
+# Returns number of guests in GUEST_LIST
+guest_count()
+{
+ set -- $1
+ echo $#
+}
+
+# check_guests_shutdown URI GUESTS
+# check if shutdown is complete on guests in "GUESTS" and returns only
+# guests that are still shutting down
+check_guests_shutdown()
+{
+ uri=$1
+ guests=$2
+
+ guests_up=
+ for guest in $guests; do
+ if ! guest_is_on "$uri" "$guest" >/dev/null 2>&1; then
+ eval_gettext "Failed to determine state of guest: \$guest. Not tracking it anymore."
+ echo
+ continue
+ fi
+ if "$guest_running"; then
+ guests_up="$guests_up $guest"
+ fi
+ done
+ echo "$guests_up"
+}
+
+# print_guests_shutdown URI BEFORE AFTER
+# Checks for differences in the lists BEFORE and AFTER and prints
+# a shutdown complete notice for guests that have finished
+print_guests_shutdown()
+{
+ uri=$1
+ before=$2
+ after=$3
+
+ for guest in $before; do
+ case " $after " in
+ *" $guest "*) continue;;
+ esac
+
+ name=$(guest_name "$uri" "$guest")
+ eval_gettext "Shutdown of guest \$name complete."
+ echo
+ done
+}
+
+# shutdown_guests_parallel URI GUESTS
+# Shutdown guests GUESTS on machine URI in parallel
+shutdown_guests_parallel()
+{
+ uri=$1
+ guests=$2
+
+ on_shutdown=
+ check_timeout=false
+ timeout=$SHUTDOWN_TIMEOUT
+ if [ $timeout -gt 0 ]; then
+ check_timeout=true
+ format=$(eval_gettext "Waiting for %d guests to shut down, %d seconds left\n")
+ else
+ slept=0
+ format=$(eval_gettext "Waiting for %d guests to shut down\n")
+ fi
+ while [ -n "$on_shutdown" ] || [ -n "$guests" ]; do
+ while [ -n "$guests" ] &&
+ [ $(guest_count "$on_shutdown") -lt "$PARALLEL_SHUTDOWN" ]; do
+ set -- $guests
+ guest=$1
+ shift
+ guests=$*
+ shutdown_guest_async "$uri" "$guest"
+ on_shutdown="$on_shutdown $guest"
+ done
+ sleep 1
+
+ set -- $guests
+ guestcount=$#
+ set -- $on_shutdown
+ shutdowncount=$#
+
+ if $check_timeout; then
+ if [ $(($timeout % 5)) -eq 0 ]; then
+ printf "$format" $(($guestcount + $shutdowncount)) "$timeout"
+ fi
+ timeout=$(($timeout - 1))
+ if [ $timeout -le 0 ]; then
+ eval_gettext "Timeout expired while shutting down domains"; echo
+ RETVAL=1
+ return
+ fi
+ else
+ slept=$(($slept + 1))
+ if [ $(($slept % 5)) -eq 0 ]; then
+ printf "$format" $(($guestcount + $shutdowncount))
+ fi
+ fi
+
+ on_shutdown_prev=$on_shutdown
+ on_shutdown=$(check_guests_shutdown "$uri" "$on_shutdown")
+ print_guests_shutdown "$uri" "$on_shutdown_prev" "$on_shutdown"
+ done
+}
+
+# stop
+# Shutdown or save guests on the configured uris
+stop() {
+ # last stop was not followed by start
+ [ -f "$LISTFILE" ] && return 0
+
+ suspending=true
+ if [ "x$ON_SHUTDOWN" = xshutdown ]; then
+ suspending=false
+ if [ $SHUTDOWN_TIMEOUT -lt 0 ]; then
+ gettext "SHUTDOWN_TIMEOUT must be equal or greater than 0"
+ echo
+ RETVAL=6
+ return
+ fi
+ fi
+
+ : >"$LISTFILE"
+ set -f
+ for uri in $URIS; do
+ set +f
+
+ test_connect "$uri" || continue
+
+ eval_gettext "Running guests on \$uri URI: "
+
+ list=$(list_guests "$uri")
+ if [ $? -eq 0 ]; then
+ empty=true
+ for uuid in $list; do
+ "$empty" || printf ", "
+ printf %s "$(guest_name "$uri" "$uuid")"
+ empty=false
+ done
+
+ if "$empty"; then
+ gettext "no running guests."
+ fi
+ echo
+ fi
+
+ if "$suspending"; then
+ transient=$(list_guests "$uri" "--transient")
+ if [ $? -eq 0 ]; then
+ empty=true
+ for uuid in $transient; do
+ if "$empty"; then
+ eval_gettext "Not suspending transient guests on URI: \$uri: "
+ empty=false
+ else
+ printf ", "
+ fi
+ printf %s "$(guest_name "$uri" "$uuid")"
+ done
+ echo
+ # reload domain list to contain only persistent guests
+ list=$(list_guests "$uri" "--persistent")
+ if [ $? -ne 0 ]; then
+ eval_gettext "Failed to list persistent guests on \$uri"
+ echo
+ RETVAL=1
+ set +f
+ return
+ fi
+ else
+ gettext "Failed to list transient guests"
+ echo
+ RETVAL=1
+ set +f
+ return
+ fi
+ fi
+
+ if [ -n "$list" ]; then
+ echo "$uri" "$list" >>"$LISTFILE"
+ fi
+ done
+ set +f
+
+ if [ -s "$LISTFILE" ]; then
+ while read uri list; do
+ if "$suspending"; then
+ eval_gettext "Suspending guests on \$uri URI..."; echo
+ else
+ eval_gettext "Shutting down guests on \$uri URI..."; echo
+ fi
+
+ if [ "$PARALLEL_SHUTDOWN" -gt 1 ] &&
+ ! "$suspending"; then
+ shutdown_guests_parallel "$uri" "$list"
+ else
+ for guest in $list; do
+ if "$suspending"; then
+ suspend_guest "$uri" "$guest"
+ else
+ shutdown_guest "$uri" "$guest"
+ fi
+ done
+ fi
+ done <"$LISTFILE"
+ else
+ rm -f "$LISTFILE"
+ fi
+
+ rm -f "$VAR_SUBSYS_LIBVIRT_GUESTS"
+}
+
+# gueststatus
+# List status of guests
+gueststatus() {
+ set -f
+ for uri in $URIS; do
+ set +f
+ echo "* $uri URI:"
+ retval run_virsh "$uri" list || echo
+ done
+ set +f
+}
+
+# rh_status
+# Display current status: whether saved state exists, and whether start
+# has been executed. We cannot use status() from the functions library,
+# since there is no external daemon process matching this init script.
+rh_status() {
+ if [ -f "$LISTFILE" ]; then
+ gettext "stopped, with saved guests"; echo
+ RETVAL=3
+ else
+ if [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ]; then
+ gettext "started"; echo
+ else
+ gettext "stopped, with no saved guests"; echo
+ fi
+ RETVAL=0
+ fi
+}
+
+# usage [val]
+# Display usage string, then exit with VAL (defaults to 2).
+usage() {
+ program_name=$0
+ eval_gettext "Usage: \$program_name {start|stop|status|restart|"\
+"condrestart|try-restart|reload|force-reload|gueststatus|shutdown}"; echo
+ exit ${1-2}
+}
+
+# See how we were called.
+if test $# != 1; then
+ usage
+fi
+case "$1" in
+ --help)
+ usage 0
+ ;;
+ start|stop|gueststatus)
+ "$1"
+ ;;
+ restart)
+ stop && start
+ ;;
+ condrestart|try-restart)
+ [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ] && stop && start
+ ;;
+ reload|force-reload)
+ # Nothing to do; we reread configuration on each invocation
+ ;;
+ status)
+ rh_status
+ ;;
+ shutdown)
+ ON_SHUTDOWN=shutdown
+ stop
+ ;;
+ *)
+ usage
+ ;;
+esac
+exit $RETVAL
--
1.8.0.1
12 years
[libvirt] [PATCH] uml: Report error if inotify fails on driver startup
by Cole Robinson
---
Someone at KVM forum was actually hitting an error here, since their system
had exceeded the max number of inotify watches somehow.
src/uml/uml_driver.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 7eedaf1..887dca6 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -509,7 +509,8 @@ umlStartup(bool privileged,
if (virFileMakePath(uml_driver->monitorDir) < 0) {
char ebuf[1024];
VIR_ERROR(_("Failed to create monitor directory %s: %s"),
- uml_driver->monitorDir, virStrerror(errno, ebuf, sizeof(ebuf)));
+ uml_driver->monitorDir,
+ virStrerror(errno, ebuf, sizeof(ebuf)));
goto error;
}
@@ -517,6 +518,10 @@ umlStartup(bool privileged,
if (inotify_add_watch(uml_driver->inotifyFD,
uml_driver->monitorDir,
IN_CREATE | IN_MODIFY | IN_DELETE) < 0) {
+ char ebuf[1024];
+ VIR_ERROR(_("Failed to create inotify watch on %s: %s"),
+ uml_driver->monitorDir,
+ virStrerror(errno, ebuf, sizeof(ebuf)));
goto error;
}
--
1.8.0.1
12 years
[libvirt] ANNOUNCE: libvirt 0.10.2.2 maintenance release
by Cole Robinson
libvirt 0.10.2.2 maintenance release is now available. This is
libvirt 0.10.2 with additional bugfixes that have accumulated
upstream since the initial release.
This release can be downloaded at:
http://libvirt.org/sources/stable_updates/libvirt-0.10.2.2.tar.gz
Changes in this version:
* dnsmasq: Fix parsing of the version number
* dnsmasq: Fix parsing of the version number
* storage: Error out earlier if the volume target path already exists
* remote: Avoid the thread race condition
* qemu: Don't free PCI device if adding it to activePciHostdevs fails
* build: fix incremental autogen.sh when no AUTHORS is present
* conf: prevent crash with no uuid in cephx auth secret
* Allow duration=0 for virsh nodesuspend
* Quote client identity in SASL whitelist log message
* Fix uninitialized variables
* nwfilter: report an error on OOM
* virsh: check the return value of virStoragePoolGetAutostart
* conf: fix uninitialized variable in virDomainListSnapshots
* rpc: don't destroy xdr before creating it in virNetMessageEncodeHeader
* virsh: do timing even for unusable connections
* virsh: use correct sizeof when allocating cpumap
* util: fix virBitmap allocation in virProcessInfoGetAffinity
* network: fix crash when portgroup has no name
* Fix leak of virNetworkPtr in LXC startup failure path
* Fix error reporting in virNetDevVethDelete
* Ensure transient def is removed if LXC start fails
* Ensure failure to create macvtap device aborts LXC start
* Avoid crash when LXC start fails with no interface target
* Specify name of target interface with macvlan error
* Treat missing driver cgroup as fatal in LXC driver
* Ensure LXC container exits if cgroups setup fails
* lxc: Don't crash if no security driver is specified in libvirt_lxc
* lxc: Avoid segfault of libvirt_lxc helper on early cleanup paths
* storage: fix logical volume cloning
* Skip deleted timers when calculting next timeout
* Warn if requesting update to non-existent timer/handle watch
* Fix virDiskNameToIndex to actually ignore partition numbers
* conf: Report sensible error for invalid disk name
* Use virNetServerRun instead of custom main loop
* storage: Fix bug of fs pool destroying
* conf: add support for booting from redirected USB devices
* qemu: allow larger discrepency between memory & currentMemory in
domain xml
* nodeinfo: support kernels that lack socket information
* virsh: save: report an error if XML file can't be read
* Doug Goldstein gained commit capability (cherry picked from commit
bf60b6b33fd8e989b56c5a5cd4ea9660cbd0e556)
* build: rerun bootstrap if AUTHORS is missing
* Fix uninitialized variable in virLXCControllerSetupDevPTS
* qemu: Don't force port=0 for SPICE
* Fix "virsh create" example
* esx: Yet another connection fix for 5.1
* qemu: Add controllers in specified order
* qemu: Wrap controllers code into dummy loop
* spec: replace scriptlets with new systemd macros
* iohelper: Don't report errors on special FDs
* qemu: Fix possible race when pausing guest
* net: Remove dnsmasq and radvd files also when destroying transient
nets
* net: Move creation of dnsmasq hosts file to function starting dnsmasq
* conf: net: Fix deadlock if assignment of network def fails
* conf: net: Fix helper for applying new network definition
* Linux Containers are not allowed to create device nodes.
* net-update docs: s/domain/network/
* iohelper: fdatasync() at the end
* qemu: Fix EmulatorPinInfo without emulatorpin
* bugfix: ip6tables rule removal
* Create temporary dir for socket
* util: do a better job of matching up pids with their binaries
* qemu: pass -usb and usb hubs earlier, so USB disks with static address
are handled properly (cherry picked from commit
81af5336acf4c765ef1201e7762d003ae0b0011e)
* qemu: Do not ignore address for USB disks (cherry picked from commit
8f708761c0d0e4eaf36bcb274d4f49fc3e0c3874)
* esx: Fix connection to ESX 5.1
* conf: fix virDomainNetGetActualDirect*() and BridgeName()
* network: use dnsmasq --bind-dynamic when available
* util: new virSocketAddrIsPrivate function
* util: capabilities detection for dnsmasq
* add ppc64 and s390x to arches where qemu-kvm exists
* qemu: Always format CPU topology
* spec: don't enable cgconfig under systemd
* qemu: Fix name comparison in qemuMonitorJSONBlockIoThrottleInfo()
* qemu: Keep QEMU host drive prefix in BlkIoTune
For info about past maintenance releases, see:
http://wiki.libvirt.org/page/Maintenance_Releases
Thanks,
Cole
12 years
[libvirt] ANNOUNCE: libvirt 0.9.11.8 maintenance release
by Cole Robinson
libvirt 0.9.11.8 maintenance release is now available. This is
libvirt 0.9.11 with additional bugfixes that have accumulated
upstream since the initial release.
This release can be downloaded at:
http://libvirt.org/sources/stable_updates/libvirt-0.9.11.8.tar.gz
Changes in this version:
* qemu: pass -usb and usb hubs earlier, so USB disks with static address
are handled properly (cherry picked from commit
81af5336acf4c765ef1201e7762d003ae0b0011e)
* qemu: Do not ignore address for USB disks (cherry picked from commit
8f708761c0d0e4eaf36bcb274d4f49fc3e0c3874)
* qemu: Fix name comparison in qemuMonitorJSONBlockIoThrottleInfo()
* qemu: Keep QEMU host drive prefix in BlkIoTune
* dnsmasq: Fix parsing of the version number
* dnsmasq: Fix parsing of the version number
* conf: fix virDomainNetGetActualDirect*() and BridgeName()
* network: use dnsmasq --bind-dynamic when available
* util: new virSocketAddrIsPrivate function
* util: capabilities detection for dnsmasq
* spec: don't enable cgconfig under systemd
For info about past maintenance releases, see:
http://wiki.libvirt.org/page/Maintenance_Releases
Thanks,
Cole
12 years
[libvirt] [PATCH 1/2] add security hook for permitting hugetlbfs access (v2)
by serge@hallyn.com
From: Serge Hallyn <serge.hallyn(a)ubuntu.com>
When a qemu domain is backed by huge pages, apparmor needs to grant the domain
rw access to files under the hugetlbfs mount point. Add a hook, called in
qemu_process.c, which ends up adding the read-write access through
virt-aa-helper. Qemu will be creating a randomly named file under the
mountpoint and unlinking it as soon as it has mmap()d it, therefore we
cannot predict the full pathname, but for the same reason it is generally
safe to provide access to $path/**.
Changelog:
v2: use virBuffer* in place of snprintf
v2: add test to virt-aa-helper-tests for the virt-aa-helper -F command used.
Signed-off-by: Serge Hallyn <serge.hallyn(a)ubuntu.com>
---
src/libvirt_private.syms | 1 +
src/qemu/qemu_process.c | 9 +++++++++
src/security/security_driver.h | 4 ++++
src/security/security_manager.c | 10 ++++++++++
src/security/security_manager.h | 3 +++
src/security/security_stack.c | 19 +++++++++++++++++++
tests/virt-aa-helper-test | 3 +++
7 files changed, 49 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7d083e4..cd798a7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1074,6 +1074,7 @@ virSecurityManagerSetTapFDLabel;
virSecurityManagerStackAddNested;
virSecurityManagerVerify;
virSecurityManagerGetMountOptions;
+virSecurityManagerSetHugepages;
# sexpr.h
sexpr_append;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ab04599..4418f33 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3482,6 +3482,15 @@ int qemuProcessStart(virConnectPtr conn,
}
virDomainAuditSecurityLabel(vm, true);
+ if (driver->hugepage_path && vm->def->mem.hugepage_backed) {
+ if (virSecurityManagerSetHugepages(driver->securityManager,
+ vm->def, driver->hugepage_path) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Unable to set huge path in security driver"));
+ goto cleanup;
+ }
+ }
+
/* Ensure no historical cgroup for this VM is lying around bogus
* settings */
VIR_DEBUG("Ensuring no historical cgroup is lying around");
diff --git a/src/security/security_driver.h b/src/security/security_driver.h
index d49b401..ad5097b 100644
--- a/src/security/security_driver.h
+++ b/src/security/security_driver.h
@@ -100,6 +100,9 @@ typedef int (*virSecurityDomainSetTapFDLabel) (virSecurityManagerPtr mgr,
int fd);
typedef char *(*virSecurityDomainGetMountOptions) (virSecurityManagerPtr mgr,
virDomainDefPtr def);
+typedef int (*virSecurityDomainSetHugepages) (virSecurityManagerPtr mgr,
+ virDomainDefPtr def,
+ const char *path);
struct _virSecurityDriver {
size_t privateDataLen;
@@ -140,6 +143,7 @@ struct _virSecurityDriver {
virSecurityDomainSetTapFDLabel domainSetSecurityTapFDLabel;
virSecurityDomainGetMountOptions domainGetSecurityMountOptions;
+ virSecurityDomainSetHugepages domainSetSecurityHugepages;
};
virSecurityDriverPtr virSecurityDriverLookup(const char *name,
diff --git a/src/security/security_manager.c b/src/security/security_manager.c
index 0ebd53b..690e4da 100644
--- a/src/security/security_manager.c
+++ b/src/security/security_manager.c
@@ -508,3 +508,13 @@ virSecurityManagerGetNested(virSecurityManagerPtr mgr)
list[1] = NULL;
return list;
}
+
+int virSecurityManagerSetHugepages(virSecurityManagerPtr mgr,
+ virDomainDefPtr vm,
+ const char *path)
+{
+ if (mgr->drv->domainSetSecurityHugepages)
+ return mgr->drv->domainSetSecurityHugepages(mgr, vm, path);
+
+ return 0;
+}
diff --git a/src/security/security_manager.h b/src/security/security_manager.h
index 1fdaf8e..2de4d30 100644
--- a/src/security/security_manager.h
+++ b/src/security/security_manager.h
@@ -112,5 +112,8 @@ char *virSecurityManagerGetMountOptions(virSecurityManagerPtr mgr,
virDomainDefPtr vm);
virSecurityManagerPtr*
virSecurityManagerGetNested(virSecurityManagerPtr mgr);
+int virSecurityManagerSetHugepages(virSecurityManagerPtr mgr,
+ virDomainDefPtr sec,
+ const char *hugepages_path);
#endif /* VIR_SECURITY_MANAGER_H__ */
diff --git a/src/security/security_stack.c b/src/security/security_stack.c
index 1094cbe..c2ccbd0 100644
--- a/src/security/security_stack.c
+++ b/src/security/security_stack.c
@@ -462,6 +462,23 @@ virSecurityStackSetTapFDLabel(virSecurityManagerPtr mgr,
return rc;
}
+static int
+virSecurityStackSetHugepages(virSecurityManagerPtr mgr,
+ virDomainDefPtr vm,
+ const char *path)
+{
+ virSecurityStackDataPtr priv = virSecurityManagerGetPrivateData(mgr);
+ virSecurityStackItemPtr item = priv->itemsHead;
+ int rc = 0;
+
+ for (; item; item = item->next) {
+ if (virSecurityManagerSetHugepages(item->securityManager, vm, path) < 0)
+ rc = -1;
+ }
+
+ return rc;
+}
+
static char *virSecurityStackGetMountOptions(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
virDomainDefPtr vm ATTRIBUTE_UNUSED) {
return NULL;
@@ -529,4 +546,6 @@ virSecurityDriver virSecurityDriverStack = {
.domainSetSecurityTapFDLabel = virSecurityStackSetTapFDLabel,
.domainGetSecurityMountOptions = virSecurityStackGetMountOptions,
+
+ .domainSetSecurityHugepages = virSecurityStackSetHugepages,
};
diff --git a/tests/virt-aa-helper-test b/tests/virt-aa-helper-test
index 21a2766..f14db8b 100755
--- a/tests/virt-aa-helper-test
+++ b/tests/virt-aa-helper-test
@@ -316,6 +316,9 @@ testme "0" "initrd is /initrd.img" "-r -u $valid_uuid" "$test_xml"
sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,<graphics*,<graphics type='sdl' display=':0.0' xauth='/home/myself/.Xauthority'/>,g" "$template_xml" > "$test_xml"
testme "0" "sdl Xauthority" "-r -u $valid_uuid" "$test_xml"
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" > "$test_xml"
+testme "0" "hugepages" "-r -u $valid_uuid -F /run/hugepages/kvm/\*\*" "$test_xml"
+
testme "0" "help" "-h"
echo "" >$output
--
1.7.10.4
12 years
[libvirt] [PATCH v3 0/2] storage: allow metadata preallocation when creating qcow2 images
by Ján Tomko
Diff to v1:
* A flag for virStorageVolCreateXML and virStorageVolCreateXMLFrom
is used instead of guessing from the allocation element.
* The flag is exposed and documented in virsh.
Diff to v2:
* merged first two patches to enable and implement the flag at the same time
* more documentation
* fixed spaces to pass syntax-check
* !! for unsigned -> bool conversion
* initialize flags in cmdVolCreateFrom and cmdVolClone
Ján Tomko (2):
storage: allow metadata preallocation when creating qcow2 images
virsh: allow metadata preallocation when creating volumes
include/libvirt/libvirt.h.in | 4 +++
src/libvirt.c | 16 ++++++++++--
src/storage/storage_backend.c | 46 ++++++++++++++++++++++++++-----------
src/storage/storage_backend.h | 3 +-
src/storage/storage_backend_fs.c | 16 ++++++++-----
src/storage/storage_driver.c | 6 ++--
tools/virsh-volume.c | 25 +++++++++++++++++---
tools/virsh.pod | 23 ++++++++++++++++--
8 files changed, 105 insertions(+), 34 deletions(-)
--
1.7.8.6
12 years
[libvirt] [PATCH] maint: mention when HACKING is rebuilt during make
by Eric Blake
I noticed that on Fedora 18, xlstproc decides to regenerate
HACKING with additional whitespace. I haven't figured out why
that is happening (although fixing it would probably be a task
for xlstproc), but in the process of investigating, I noticed
that 'make HACKING' was completely silent, for no good reason.
* Makefile.am (gen-ChangeLog, gen-AUTHORS, NEWS)
($(top_srcdir)/HACKING): Mention which files we are generating.
---
The F18 xsltproc is from libxslt-1.1.27; it is generating additional
newlines in HACKING when compared against libxslt-1.1.26 of RHEL 6.3;
any hints on making HACKING idempotent in spite of different libxslt
versions would be appreciated.
Makefile.am | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 7b3a335..f8e669a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
-## Copyright (C) 2005-2011 Red Hat, Inc.
+## Copyright (C) 2005-2012 Red Hat, Inc.
## See COPYING.LIB for the License of this software
LCOV = lcov
@@ -35,7 +35,7 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libvirt.pc
NEWS: $(top_srcdir)/docs/news.xsl $(top_srcdir)/docs/news.html.in
- -@(if [ -x $(XSLTPROC) ] ; then \
+ $(AM_V_GEN)(if [ -x $(XSLTPROC) ] ; then \
$(XSLTPROC) --nonet $(top_srcdir)/docs/news.xsl \
$(top_srcdir)/docs/news.html.in \
| perl -0777 -pe 's/\n\n+$$/\n/' \
@@ -44,7 +44,7 @@ NEWS: $(top_srcdir)/docs/news.xsl $(top_srcdir)/docs/news.html.in
$(top_srcdir)/HACKING: $(top_srcdir)/docs/hacking1.xsl $(top_srcdir)/docs/hacking2.xsl \
$(top_srcdir)/docs/wrapstring.xsl $(top_srcdir)/docs/hacking.html.in
- -@(if [ -x $(XSLTPROC) ] ; then \
+ $(AM_V_GEN)(if [ -x $(XSLTPROC) ] ; then \
$(XSLTPROC) --nonet $(top_srcdir)/docs/hacking1.xsl $(top_srcdir)/docs/hacking.html.in | \
$(XSLTPROC) --nonet $(top_srcdir)/docs/hacking2.xsl - \
| perl -0777 -pe 's/\n\n+$$/\n/' \
@@ -86,7 +86,7 @@ dist-hook: gen-ChangeLog gen-AUTHORS
gen_start_date = 2009-07-04
.PHONY: gen-ChangeLog
gen-ChangeLog:
- if test -d .git; then \
+ $(AM_V_GEN)if test -d .git; then \
$(top_srcdir)/build-aux/gitlog-to-changelog \
--since=$(gen_start_date) > $(distdir)/cl-t; \
rm -f $(distdir)/ChangeLog; \
@@ -95,7 +95,7 @@ gen-ChangeLog:
.PHONY: gen-AUTHORS
gen-AUTHORS:
- if test -d .git; then \
+ $(AM_V_GEN)if test -d .git; then \
out="`git log --pretty=format:'%aN <%aE>' | sort -u`" && \
cat $(srcdir)/AUTHORS.in | perl -p -e "s/#authorslist#/$$out/" > \
$(distdir)/AUTHORS-tmp && \
--
1.8.0.1
12 years