[libvirt] [PATCH 4/6] New files to glue domain and storage together

Osier Yang jyang at redhat.com
Wed Jan 23 11:04:36 UTC 2013


This creates src/conf/domain_storage.h and src/conf/storage_conf.c,
which defines a driver contains internal APIs to glue the domain
and storage. Currently there is only one API, translateDiskSourcePool,
which is to translate the specified pool/volume into the the real
underlying disk source. Later patch will implement API.
---
 src/Makefile.am           |    3 ++-
 src/conf/domain_storage.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 src/conf/domain_storage.h |   37 +++++++++++++++++++++++++++++++++++++
 src/libvirt_private.syms  |    4 ++++
 4 files changed, 88 insertions(+), 1 deletions(-)
 create mode 100644 src/conf/domain_storage.c
 create mode 100644 src/conf/domain_storage.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 070a089..d664c48 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -203,7 +203,8 @@ DOMAIN_CONF_SOURCES =						\
 		conf/domain_conf.c conf/domain_conf.h		\
 		conf/domain_audit.c conf/domain_audit.h		\
 		conf/domain_nwfilter.c conf/domain_nwfilter.h	\
-		conf/snapshot_conf.c conf/snapshot_conf.h
+		conf/snapshot_conf.c conf/snapshot_conf.h	\
+		conf/domain_storage.c conf/domain_storage.h
 
 DOMAIN_EVENT_SOURCES =						\
 		conf/domain_event.c conf/domain_event.h
diff --git a/src/conf/domain_storage.c b/src/conf/domain_storage.c
new file mode 100644
index 0000000..b5f6ee4
--- /dev/null
+++ b/src/conf/domain_storage.c
@@ -0,0 +1,45 @@
+/*
+ * domain_storage.c: Internal APIs to glue domain and storage
+ *
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Osier Yang <jyang at redhat.com>
+ */
+
+#include <config.h>
+
+#include "internal.h"
+
+#include "datatypes.h"
+#include "domain_conf.h"
+#include "domain_storage.h"
+
+static virDomainStorageDriverPtr domainStorageDriver;
+
+void
+virRegisterDomainStorageDriver(virDomainStorageDriverPtr driver) {
+    domainStorageDriver = driver;
+}
+
+int
+virDomainStorageTranslateDiskSourcePool(virConnectPtr conn,
+                                        virDomainDefPtr def) {
+    if (domainStorageDriver != NULL)
+        return domainStorageDriver->translateDiskSourcePool(conn, def);
+    return 0;
+}
+
diff --git a/src/conf/domain_storage.h b/src/conf/domain_storage.h
new file mode 100644
index 0000000..143b476
--- /dev/null
+++ b/src/conf/domain_storage.h
@@ -0,0 +1,37 @@
+/*
+ * domain_storage.h: Internal APIs to glue domain and storage
+ *
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Osier Yang <jyang at redhat.com>
+ */
+#ifndef DOMAIN_STORAGE_H
+# define DOMAIN_STORAGE_H
+
+typedef int (*virDomainStorageDiskSourcePoolTranslate)(virConnectPtr conn,
+                                                       virDomainDefPtr def);
+struct _virDomainStorageDriver {
+    virDomainStorageDiskSourcePoolTranslate translateDiskSourcePool;
+};
+typedef struct _virDomainStorageDriver virDomainStorageDriver;
+typedef virDomainStorageDriver *virDomainStorageDriverPtr;
+
+void virRegisterDomainStorageDriver(virDomainStorageDriverPtr driver);
+int virDomainStorageTranslateDiskSourcePool(virConnectPtr conn,
+                                            virDomainDefPtr def);
+
+#endif /* DOMAIN_STORAGE_H */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d14be41..04aa24c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -616,6 +616,10 @@ virDomainConfNWFilterTeardown;
 virDomainConfVMNWFilterTeardown;
 
 
+# domain_storage.h
+virDomainStorageTranslateDiskSourcePool;
+virRegisterDomainStorageDriver;
+
 # ebtables.h
 ebtablesAddForwardAllowIn;
 ebtablesAddForwardPolicyReject;
-- 
1.7.7.6




More information about the libvir-list mailing list