Index: libvirt/qemud/conf.c
===================================================================
--- libvirt.orig/qemud/conf.c
+++ libvirt/qemud/conf.c
@@ -555,6 +555,14 @@ static struct qemud_vm_def *qemudParseXM
     prop = NULL;
 
 
+    /* Extract autostart attribute */
+    obj = xmlXPathEval(BAD_CAST "/domain/@autostart='true'", ctxt);
+    if (obj && obj->type == XPATH_BOOLEAN && obj->boolval) {
+        def->autostart = 1;
+    }
+    xmlXPathFreeObject(obj);
+
+
     /* Extract domain name */
     obj = xmlXPathEval(BAD_CAST "string(/domain/name[1])", ctxt);
     if ((obj == NULL) || (obj->type != XPATH_STRING) ||
@@ -1459,6 +1467,14 @@ static struct qemud_network_def *qemudPa
     }
 
 
+    /* Extract autostart attribute */
+    obj = xmlXPathEval(BAD_CAST "/network/@autostart='true'", ctxt);
+    if (obj && obj->type == XPATH_BOOLEAN && obj->boolval) {
+        def->autostart = 1;
+    }
+    xmlXPathFreeObject(obj);
+
+
     /* Extract network name */
     obj = xmlXPathEval(BAD_CAST "string(/network/name[1])", ctxt);
     if ((obj == NULL) || (obj->type != XPATH_STRING) ||
@@ -1665,11 +1681,44 @@ int qemudScanConfigDir(struct qemud_serv
     return 0;
 }
 
+static
+void qemudAutostartConfigs(struct qemud_server *server) {
+    struct qemud_network *network;
+    struct qemud_vm *vm;
+
+    network = server->inactivenetworks;
+    while (network != NULL) {
+        struct qemud_network *next = network->next;
+
+        if (network->def->autostart &&
+            qemudNetworkStart(server, network))
+            qemudLog(QEMUD_ERR, "Failed to autostart network '%s'",
+                     network->def->name);
+
+        network = next;
+    }
+
+    vm = server->inactivevms;
+    while (vm != NULL) {
+        struct qemud_vm *next = vm->next;
+
+        if (vm->def->autostart &&
+            qemudDomainStart(server, vm))
+            qemudLog(QEMUD_ERR, "Failed to autostart VM '%s'",
+                     vm->def->name);
+
+        vm = next;
+    }
+}
+
 /* Scan for all guest and network config files */
 int qemudScanConfigs(struct qemud_server *server) {
     if (qemudScanConfigDir(server, server->configDir, 1) < 0)
         return -1;
-    return qemudScanConfigDir(server, server->networkConfigDir, 0);
+    if (qemudScanConfigDir(server, server->networkConfigDir, 0) < 0)
+        return -1;
+    qemudAutostartConfigs(server);
+    return 0;
 }
 
 /* Simple grow-on-demand string buffer */
@@ -1751,13 +1800,17 @@ char *qemudGenerateXML(struct qemud_serv
         goto cleanup;
     }
 
-    if (vm->id >= 0 && live) {
-        if (qemudBufferPrintf(&buf, "<domain type='%s' id='%d'>\n", type, vm->id) < 0)
+    if (qemudBufferPrintf(&buf, "<domain type='%s'", type) < 0)
+        goto no_memory;
+
+    if (vm->id >= 0 && live && qemudBufferPrintf(&buf, " id='%d'", vm->id) < 0)
+        goto no_memory;
+
+    if (def->autostart && qemudBufferAdd(&buf, " autostart='true'") < 0)
             goto no_memory;
-    } else {
-        if (qemudBufferPrintf(&buf, "<domain type='%s'>\n", type) < 0)
+
+    if (qemudBufferAdd(&buf, ">\n") < 0)
             goto no_memory;
-    }
 
     if (qemudBufferPrintf(&buf, "  <name>%s</name>\n", def->name) < 0)
         goto no_memory;
@@ -1967,7 +2020,13 @@ char *qemudGenerateNetworkXML(struct qem
     buf.used = 0;
     buf.data = malloc(buf.len);
 
-    if (qemudBufferPrintf(&buf, "<network>\n") < 0)
+    if (qemudBufferAdd(&buf, "<network") < 0)
+        goto no_memory;
+
+    if (def->autostart && qemudBufferAdd(&buf, " autostart='true'") < 0)
+        goto no_memory;
+
+    if (qemudBufferAdd(&buf, ">\n") < 0)
         goto no_memory;
 
     if (qemudBufferPrintf(&buf, "  <name>%s</name>\n", def->name) < 0)
Index: libvirt/qemud/internal.h
===================================================================
--- libvirt.orig/qemud/internal.h
+++ libvirt/qemud/internal.h
@@ -176,6 +176,8 @@ struct qemud_vm_def {
     unsigned char uuid[QEMUD_UUID_RAW_LEN];
     char name[QEMUD_MAX_NAME_LEN];
 
+    unsigned int autostart : 1;
+
     int memory;
     int maxmem;
     int vcpus;
@@ -226,6 +228,8 @@ struct qemud_network_def {
     unsigned char uuid[QEMUD_UUID_RAW_LEN];
     char name[QEMUD_MAX_NAME_LEN];
 
+    unsigned int autostart : 1;
+
     char bridge[BR_IFNAME_MAXLEN];
     int disableSTP;
     int forwardDelay;
