Skip to contentSkip to conversation

kvm tools: Clean up remove/rename in 9p

PATCH New Sasha Levin 1 participant 2 messages Nov 7, 2011 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 kvm tools: Clean up remove/rename in 9p

Trivial cleanups.

---
 tools/kvm/virtio/9p.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
tools/kvm/virtio/9p.c +4 -6
index 2392bd1..8104ac4 100644
@@ -683,13 +683,11 @@ static void virtio_p9_remove(struct p9_dev *p9dev,
 	int ret;
 	u32 fid_val;
 	struct p9_fid *fid;
-	char full_path[PATH_MAX];
 
 	virtio_p9_pdu_readf(pdu, "d", &fid_val);
 	fid = &p9dev->fids[fid_val];
 
-	sprintf(full_path, "%s", fid->abs_path);
-	ret = remove(full_path);
+	ret = remove(fid->abs_path);
 	if (ret < 0)
 		goto err_out;
 	*outlen = pdu->write_offset;
@@ -698,7 +696,7 @@ static void virtio_p9_remove(struct p9_dev *p9dev,
 
 err_out:
 	virtio_p9_error_reply(p9dev, pdu, errno, outlen);
-	return;	
+	return;
 }
 
 static void virtio_p9_rename(struct p9_dev *p9dev,
@@ -724,9 +722,9 @@ static void virtio_p9_rename(struct p9_dev *p9dev,
 
 err_out:
 	virtio_p9_error_reply(p9dev, pdu, errno, outlen);
-	return;	
+	return;
 }
-			       
+
 static void virtio_p9_readlink(struct p9_dev *p9dev,
 			       struct p9_pdu *pdu, u32 *outlen)
 {
Signature · 1 line
1.7.7.2
#1 lore raw

PATCH 2/2 kvm tools: Create /etc/passwd in shared rootfs

This patch creates a dummy /etc/passwd on guest creation.

This is done because some applications (read: git) get angry when they can't find current user in /etc/passwd.

---
 tools/kvm/builtin-setup.c |   15 ++++++++++++++-
 tools/kvm/guest/passwd    |    1 +
 2 files changed, 15 insertions(+), 1 deletions(-)
 create mode 100644 tools/kvm/guest/passwd
tools/kvm/builtin-setup.c +14 -1
index 7deb0ed..fb8a1b3 100644
@@ -131,6 +131,15 @@ static int copy_init(const char *guestfs_name)
 	return copy_file("guest/init", path);
 }
 
+static int copy_passwd(const char *guestfs_name)
+{
+	char path[PATH_MAX];
+
+	snprintf(path, PATH_MAX, "%s%s/etc/passwd", kvm__get_dir(), guestfs_name);
+
+	return copy_file("guest/passwd", path);
+}
+
 static int make_guestfs_symlink(const char *guestfs_name, const char *path)
 {
 	char target[PATH_MAX];
@@ -197,7 +206,11 @@ static int do_setup(const char *guestfs_name)
 		make_guestfs_symlink(guestfs_name, guestfs_symlinks[i]);
 	}
 
-	return copy_init(guestfs_name);
+	ret = copy_init(guestfs_name);
+	if (ret < 0)
+		return ret;
+
+	return copy_passwd(guestfs_name);
 }
 
 int kvm_setup_create_new(const char *guestfs_name)
tools/kvm/guest/passwd new file +1 -0
new file mode 100644
index 0000000..eb85a55
@@ -0,0 +1 @@
+root:x:0:0:root:/root:/bin/sh
Signature · 1 line
1.7.7.2