8000 kvm: Set hostname inside kvm container. Closes #2189 by squall0gd · Pull Request #2190 · rkt/rkt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

kvm: Set hostname inside kvm container. Closes #2189 #2190

Merged
merged 1 commit into from
Feb 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions stage1/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,16 @@ func getArgsEnv(p *stage1commontypes.Pod, flavor string, debug bool, n *networki
nsargs := stage1initcommon.VolumesToKvmDiskArgs(p.Manifest.Volumes)
args = append(args, nsargs...)

// set hostname inside pod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not a problem, please add a comment referring to systemd-hostname why writing /etc/hostname is enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// According to systemd manual (https://www.freedesktop.org/software/systemd/man/hostname.html) :
// "The /etc/hostname file configures the name of the local system that is set
// during boot using the sethostname system call"
hostname := stage1initcommon.GetMachineID(p)
hostnamePath := filepath.Join(common.Stage1RootfsPath(p.Root), "etc/hostname")
if err := ioutil.WriteFile(hostnamePath, []byte(hostname), 0644); err != nil {
return nil, nil, fmt.Errorf("error writing %s, %s", hostnamePath, err)
}

// lkvm requires $HOME to be defined,
// see https://github.com/coreos/rkt/issues/1393
if os.Getenv("HOME") == "" {
Expand Down
0