* @nicindexes: list of network interface indexes
* @partition: name of the slice to place the machine in
* @maxthreads: maximum number of threads the VM process can use
+ * @daemonDomainShutdown: shutdown of domains on host shutdown is done by the
+ * daemon instead of the libvirt-guests script
*
* Returns 0 on success, -1 on fatal error, or -2 if systemd-machine is not available
*/
size_t nnicindexes,
int *nicindexes,
const char *partition,
- unsigned int maxthreads)
+ unsigned int maxthreads,
+ bool daemonDomainShutdown)
{
int rc;
GDBusConnection *conn;
uuid, 16, sizeof(unsigned char));
gnicindexes = g_variant_new_fixed_array(G_VARIANT_TYPE("i"),
nicindexes, nnicindexes, sizeof(int));
- gprops = g_variant_new_parsed("[('Slice', <%s>),"
- " ('After', <['libvirtd.service', %s]>),"
- " ('Before', <['virt-guest-shutdown.target']>)]",
- slicename,
- servicename);
+
+ if (daemonDomainShutdown) {
+ /* When domains are shut down by the daemon rather than the
+ * "libvirt-guests" script we need ensure that their unit
+ * is ordered so that it's shutdown after the libvirt daemon itself */
+ gprops = g_variant_new_parsed("[('Slice', <%s>),"
+ " ('Before', <['libvirtd.service', %s]>)]",
+ slicename,
+ servicename);
+ } else {
+ gprops = g_variant_new_parsed("[('Slice', <%s>),"
+ " ('After', <['libvirtd.service', %s]>),"
+ " ('Before', <['virt-guest-shutdown.target']>)]",
+ slicename,
+ servicename);
+ }
+
message = g_variant_new("(s@ayssus@ai@a(sv))",
name,
guuid,
123,
true,
0, NULL,
- "highpriority.slice", 0) < 0) {
+ "highpriority.slice", 0,
+ false) < 0) {
fprintf(stderr, "%s", "Failed to create LXC machine\n");
return -1;
}
123,
false,
0, NULL,
- NULL, 0) < 0) {
+ NULL,
+ 0,
+ true) < 0) {
fprintf(stderr, "%s", "Failed to create KVM machine\n");
return -1;
}
123,
false,
0, NULL,
- NULL, 0)) == 0) {
+ NULL, 0, false)) == 0) {
g_unsetenv("FAIL_NO_SERVICE");
fprintf(stderr, "%s", "Unexpected create machine success\n");
return -1;
123,
false,
0, NULL,
- NULL, 0)) == 0) {
+ NULL, 0, false)) == 0) {
g_unsetenv("FAIL_NOT_REGISTERED");
fprintf(stderr, "%s", "Unexpected create machine success\n");
return -1;
123,
false,
0, NULL,
- NULL, 0)) == 0) {
+ NULL, 0, false)) == 0) {
g_unsetenv("FAIL_BAD_SERVICE");
fprintf(stderr, "%s", "Unexpected create machine success\n");
return -1;
123,
true,
nnicindexes, nicindexes,
- "highpriority.slice", 2) < 0) {
+ "highpriority.slice", 2, false) < 0) {
fprintf(stderr, "%s", "Failed to create LXC machine\n");
return -1;
}