kvm tools: Don't copy network autoconfiguration script
PATCH 1/2 kvm tools: Don't copy network autoconfiguration script
Network autoconfiguration was moved to the kernel, but the setup code still tried to copy the script over to the rootfs. This prevented from /virt/ to be properly created.
--- tools/kvm/builtin-setup.c | 13 ------------- 1 files changed, 0 insertions(+), 13 deletions(-)
tools/kvm/builtin-setup.c +0 -13
@@ -129,15 +129,6 @@ static int copy_init(const char *guestfs_name)return copy_file ("guest/init" , path); } -static int copy_net (const char *guestfs_name) -{ -char path[PATH_MAX ]; - -snprintf (path,PATH_MAX ,"%s%s%s/virt/setnet.sh" ,HOME_DIR ,KVM_PID_FILE_PATH , guestfs_name); - -return copy_file ("guest/setnet.sh" , path); -} -static int make_guestfs_symlink (const char *guestfs_name,const char *path) {char target[PATH_MAX ];
@@ -195,10 +186,6 @@ static int do_setup(const char *guestfs_name)make_guestfs_symlink (guestfs_name, guestfs_symlinks[i]); } - ret =copy_net (guestfs_name); -if (ret <0 ) -return ret; -return copy_init (guestfs_name); }
Signature · 1 line
1.7.6.1
PATCH 2/2 kvm tools: Use host's resolv.conf within the guest
Since kernel IP autoconfiguration doesn't set up /etc/resolv.conf, we'll use the one located within the host, since this was anyway what we simulated within the DHCP offer packets.
--- tools/kvm/builtin-run.c | 2 ++ tools/kvm/builtin-setup.c | 9 +++++++++ tools/kvm/include/kvm/builtin-setup.h | 1 + 3 files changed, 12 insertions(+), 0 deletions(-)
tools/kvm/builtin-run.c +2 -0
@@ -129,6 +129,7 @@ static int img_name_parser(const struct option *opt, const char *arg, int unset)die ("Unable to initialize virtio 9p" );if (virtio_9p__register (kvm,"/" ,"hostfs" ) <0 )die ("Unable to initialize virtio 9p" ); +kvm_setup_resolv (arg); using_rootfs = custom_rootfs =1 ;return 0 ; }
@@ -750,6 +751,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)char tmp[PATH_MAX ];kvm_setup_create_new ("default" ); +kvm_setup_resolv ("default" );snprintf (tmp,PATH_MAX ,"%s%s%s" ,HOME_DIR ,KVM_PID_FILE_PATH ,"default" );if (virtio_9p__register (kvm, tmp,"/dev/root" ) <0 )
tools/kvm/builtin-setup.c +9 -0
@@ -168,6 +168,15 @@ static void make_guestfs_dir(const char *guestfs_name, const char *dir)make_dir (name); } +void kvm_setup_resolv (const char *guestfs_name) +{ +char path[PATH_MAX ]; + +snprintf (path,PATH_MAX ,"%s%s%s/etc/resolv.conf" ,HOME_DIR ,KVM_PID_FILE_PATH , guestfs_name); + +copy_file ("/etc/resolv.conf" , path); +} +static int do_setup (const char *guestfs_name) {unsigned int i;
tools/kvm/include/kvm/builtin-setup.h +1 -0
@@ -4,5 +4,6 @@int kvm_cmd_setup (int argc,const char **argv,const char *prefix);void kvm_setup_help (void );int kvm_setup_create_new (const char *guestfs_name); +void kvm_setup_resolv (const char *guestfs_name);#endif
Signature · 1 line
1.7.6.1
Re: [PATCH 2/2] kvm tools: Use host's resolv.conf within the guest
Quoted 5 lines · Sasha Levin
Since kernel IP autoconfiguration doesn't set up
/etc/resolv.conf, we'll use the one located within the host, since this was anyway what we simulated within the DHCP offer packets.Signed-off-by Sasha Levin <[email protected]>
Wouldn't a symlink to /host/etc/resolv.conf be more appropriate? Remember, we're supposed to only need to setup the shared rootfs once.
Re: [PATCH 2/2] kvm tools: Use host's resolv.conf within the guest
Quoted 9 lines · Pekka Enberg
Quoted 5 lines · Sasha Levin
Since kernel IP autoconfiguration doesn't set up
/etc/resolv.conf, we'll use the one located within the host, since this was anyway what we simulated within the DHCP offer packets.Signed-off-by Sasha Levin <[email protected]>Wouldn't a symlink to /host/etc/resolv.conf be more appropriate? Remember, we're supposed to only need to setup the shared rootfs once.
It would mean the guest can screw up with the host's networking.
Signature · 1 line
Sasha.
Re: [PATCH 2/2] kvm tools: Use host's resolv.conf within the guest
Quoted 6 lines · Sasha Levin
Quoted 5 lines · Pekka Enberg
Quoted 4 lines · Sasha Levin
Since kernel IP autoconfiguration doesn't set up
/etc/resolv.conf, we'll use the one located within the host, since this was anyway what we simulated within the DHCP offer packets.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Sasha Levin<[email protected]>Wouldn't a symlink to /host/etc/resolv.conf be more appropriate? Remember, we're supposed to only need to setup the shared rootfs once.
It would mean the guest can screw up with the host's networking.
How? You're not supposed to run the tool.
Pekka
Re: [PATCH 2/2] kvm tools: Use host's resolv.conf within the guest
Quoted 7 lines · Pekka Enberg
Quoted 6 lines · Sasha Levin
Quoted 5 lines · Pekka Enberg
Quoted 4 lines · Sasha Levin
Since kernel IP autoconfiguration doesn't set up
/etc/resolv.conf, we'll use the one located within the host, since this was anyway what we simulated within the DHCP offer packets.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Sasha Levin<[email protected]>Wouldn't a symlink to /host/etc/resolv.conf be more appropriate? Remember, we're supposed to only need to setup the shared rootfs once.
It would mean the guest can screw up with the host's networking.
How? You're not supposed to run the tool.
Hm? If you it to the host's resolv.conf, a guest can edit host's file, no?
Might even be not on purpose... For example, simply running dhcpcd on the guest.
Signature · 1 line
Sasha.
Re: [PATCH 2/2] kvm tools: Use host's resolv.conf within the guest
Quoted 5 lines · Sasha Levin
Hm? If you it to the host's resolv.conf, a guest can edit host's file, no?
Might even be not on purpose... For example, simply running dhcpcd on the guest.
How is that going to happen if you're not running kvmtool as root?
Re: [PATCH 2/2] kvm tools: Use host's resolv.conf within the guest
Quoted 8 lines · Pekka Enberg
Quoted 5 lines · Sasha Levin
Hm? If you it to the host's resolv.conf, a guest can edit host's file, no?
Might even be not on purpose... For example, simply running dhcpcd on the guest.
How is that going to happen if you're not running kvmtool as root?
In that case, dhcpcd in the guest will simply break because it can't modify resolv.conf, no?
Signature · 1 line
Sasha.
Re: [PATCH 2/2] kvm tools: Use host's resolv.conf within the guest
Quoted 5 lines · Sasha Levin
Quoted 4 lines · Pekka Enberg
Quoted 3 lines · Sasha Levin
Hm? If you it to the host's resolv.conf, a guest can edit host's file, no?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Might even be not on purpose... For example, simply running dhcpcd on the guest.
How is that going to happen if you're not running kvmtool as root?
In that case, dhcpcd in the guest will simply break because it can't modify resolv.conf, no?
Yes. Why is that a problem? You're not supposed to launch a dhcp client when using shared rootfs because kvmtool takes care of that for you.
Pekka
Re: [PATCH 2/2] kvm tools: Use host's resolv.conf within the guest
Quoted 9 lines · Pekka Enberg
Quoted 8 lines · Sasha Levin
Quoted 7 lines · Pekka Enberg
Quoted 5 lines · Sasha Levin
Hm? If you it to the host's resolv.conf, a guest can edit host's file, no?
Might even be not on purpose... For example, simply running dhcpcd on the guest.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
How is that going to happen if you're not running kvmtool as root?
In that case, dhcpcd in the guest will simply break because it can't modify resolv.conf, no?
Yes. Why is that a problem? You're not supposed to launch a dhcp client when using shared rootfs because kvmtool takes care of that for you.
Why? Testing a brand new dhcp client for example :)
We can't block the user from editing guest configuration files...
Signature · 1 line
Sasha.