Created
March 15, 2017 14:24
-
-
Save sameo/bcdcfdc8097d61bc8dc616577ef6bfd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/proxy/vm.go b/proxy/vm.go | |
index 01c3de9..cff59d3 100644 | |
--- a/proxy/vm.go | |
+++ b/proxy/vm.go | |
@@ -16,7 +16,7 @@ package main | |
import ( | |
"bufio" | |
- "encoding/hex" | |
+// "encoding/hex" | |
"fmt" | |
"net" | |
"os" | |
@@ -118,7 +118,7 @@ func (vm *vm) dump(lvl glog.Level, data []byte) { | |
if !glog.V(lvl) { | |
return | |
} | |
- glog.Infof("\n%s", hex.Dump(data)) | |
+ glog.Infof("DUMP: \n%s", string(data)) | |
} | |
func (vm *vm) findSession(seq uint64) *ioSession { | |
diff --git a/src/mount.c b/src/mount.c | |
index afb51d9..55bad24 100644 | |
--- a/src/mount.c | |
+++ b/src/mount.c | |
@@ -28,6 +28,7 @@ | |
#include "mount.h" | |
#include "common.h" | |
#include "namespace.h" | |
+#include "pod.h" | |
/** Mounts that will be ignored. | |
* | |
@@ -215,7 +216,7 @@ cc_oci_perform_mount (const struct cc_oci_mount *m, gboolean dry_run) | |
* \return \c true on success, else \c false. | |
*/ | |
static gboolean | |
-cc_handle_mounts(struct cc_oci_config *config, GSList *mounts) | |
+cc_handle_mounts(struct cc_oci_config *config, GSList *mounts, gboolean volume) | |
{ | |
GSList *l; | |
gboolean ret; | |
@@ -238,13 +239,18 @@ cc_handle_mounts(struct cc_oci_config *config, GSList *mounts) | |
struct cc_oci_mount *m = (struct cc_oci_mount *)l->data; | |
if (cc_oci_mount_ignore (m)) { | |
- g_debug ("ignoring mount %s", m->mnt.mnt_dir); | |
continue; | |
} | |
- g_snprintf (m->dest, sizeof (m->dest), | |
- "%s%s", | |
- workload_dir, m->mnt.mnt_dir); | |
+ if (! cc_pod_is_vm(config) && volume) { | |
+ g_snprintf (m->dest, sizeof (m->dest), | |
+ "%s/%s/rootfs/%s", workload_dir, config->optarg_container_id, m->mnt.mnt_dir); | |
+ } else { | |
+ g_snprintf (m->dest, sizeof (m->dest), | |
+ "%s%s", | |
+ workload_dir, m->mnt.mnt_dir); | |
+ } | |
+ g_critical ("Mount destination: %s", m->dest); | |
if (m->mnt.mnt_fsname[0] == '/') { | |
if (stat (m->mnt.mnt_fsname, &st)) { | |
@@ -316,7 +322,7 @@ cc_oci_handle_mounts (struct cc_oci_config *config) | |
return false; | |
} | |
- return cc_handle_mounts(config, config->oci.mounts); | |
+ return cc_handle_mounts(config, config->oci.mounts, true); | |
} | |
/*! | |
@@ -333,7 +339,7 @@ cc_pod_handle_mounts (struct cc_oci_config *config) | |
return true; | |
} | |
- return cc_handle_mounts(config, config->pod->rootfs_mounts); | |
+ return cc_handle_mounts(config, config->pod->rootfs_mounts, false); | |
} | |
/*! | |
@@ -441,7 +447,7 @@ cc_oci_handle_unmounts (const struct cc_oci_config *config) | |
* since namespace created by unshare in \ref cc_oci_ns_setup | |
* is destroyed when qemu ends | |
*/ | |
- if (! mountns) { | |
+ if (! mountns && cc_pod_is_vm(config)) { | |
return true; | |
} | |
diff --git a/src/oci.c b/src/oci.c | |
index 06f0ebf..f4c3ec0 100644 | |
--- a/src/oci.c | |
+++ b/src/oci.c | |
@@ -522,6 +522,11 @@ cc_oci_cleanup (struct cc_oci_config *config) | |
return false; | |
} | |
+ /* Pod unmounts should happen after the volume unmounts */ | |
+ if (! cc_pod_handle_unmounts(config)) { | |
+ return false; | |
+ } | |
+ | |
if (! cc_oci_state_file_delete (config)) { | |
return false; | |
} | |
@@ -1034,11 +1039,6 @@ cc_oci_stop (struct cc_oci_config *config, | |
return false; | |
} | |
- if (! cc_pod_handle_unmounts(config)) { | |
- g_critical ("failed to handle pod unmounts"); | |
- return false; | |
- } | |
- | |
/* Allow the proxy to clean up resources */ | |
if (cc_pod_is_vm (config) && | |
! cc_proxy_cmd_bye (config->proxy, config->optarg_container_id)) { | |
diff --git a/src/pod.c b/src/pod.c | |
index 1f32bc0..6d0b03c 100644 | |
--- a/src/pod.c | |
+++ b/src/pod.c | |
@@ -471,7 +471,7 @@ cc_pod_is_sandbox(struct cc_oci_config *config) | |
* \return \c true if the container is a virtual machine, \c false otherwise | |
*/ | |
gboolean | |
-cc_pod_is_vm(struct cc_oci_config *config) | |
+cc_pod_is_vm(const struct cc_oci_config *config) | |
{ | |
if (config && config->pod && ! config->pod->sandbox) { | |
return false; | |
diff --git a/src/pod.h b/src/pod.h | |
index a43b839..3bcd641 100644 | |
--- a/src/pod.h | |
+++ b/src/pod.h | |
@@ -35,6 +35,6 @@ gboolean cc_pod_container_create (struct cc_oci_config *config); | |
gboolean cc_pod_container_start (struct cc_oci_config *config); | |
const gchar *cc_pod_container_id(struct cc_oci_config *config); | |
gboolean cc_pod_is_sandbox(struct cc_oci_config *config); | |
-gboolean cc_pod_is_vm(struct cc_oci_config *config); | |
+gboolean cc_pod_is_vm(const struct cc_oci_config *config); | |
#endif /* _CC_POD_H */ | |
diff --git a/tests/pod_test.c b/tests/pod_test.c | |
index 0d923d1..bad75cb 100644 | |
--- a/tests/pod_test.c | |
+++ b/tests/pod_test.c | |
@@ -33,7 +33,7 @@ | |
const gchar *cc_pod_container_id(struct cc_oci_config *config); | |
gboolean cc_pod_is_sandbox(struct cc_oci_config *config); | |
-gboolean cc_pod_is_vm(struct cc_oci_config *config); | |
+gboolean cc_pod_is_vm(const struct cc_oci_config *config); | |
START_TEST(test_cc_pod_container_id) { | |
struct cc_oci_config *config = NULL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment